Re:Google HTML/CSS Style Guide – Omit Optional Tags
by mbrock on Saturday September 17, 2016 @02:58PM
(#12521852)
XPath can't run on HTML5, you have to parse it into DOM first, so there's no problem.
[ Parent
| on HN ]
Re:Google HTML/CSS Style Guide – Omit Optional Tags
by j4_james on Saturday September 17, 2016 @03:22PM
(#12521974)
HTML5 does actually support an XHTML serialisation[1] if you need your content to be easily parsed with XML tools.
Re:Google HTML/CSS Style Guide – Omit Optional Tags
by mbrock on Saturday September 17, 2016 @03:33PM
(#12522035)
Ah, yeah, indeed, thanks for the clarification.
Re:Google HTML/CSS Style Guide – Omit Optional Tags
by gsnedders on Sunday September 18, 2016 @05:19AM
(#12524552)
XPath is defined as operating on an XML infoset, not a DOM. And there's no defined mapping from a DOM to an XML infoset anywhere. So really we're in undefined territory.
In reality in browsers, that coercion to an infoset never actually happens, and XPath is matched directly against the DOM, which leads to differences in edge-cases (notably, adjacent text nodes, which the DOM allows and the XML infoset does not).