3 ms·
This is going to wreck havoc on XPATH selectors across the world.
by original_idea 10y ago
This is going to wreck havoc on XPATH selectors across the world.
- mbrock 10y agoXPath can't run on HTML5, you have to parse it into DOM first, so there's no problem.
- j4_james 10y agoHTML5 does actually support an XHTML serialisation[1] if you need your content to be easily parsed with XML tools. [1] https://www.w3.org/TR/html5/the-xhtml-syntax.html https://www.w3.org/TR/html5/the-xhtml-syntax.html
- mbrock 10y agoAh, yeah, indeed, thanks for the clarification.
- gsnedders 10y agoXPath 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).
- gsnedders 10y agoWhy? The elements are still there in the DOM and presumably in an XML infoset you create from the DOM produced from the HTML parser.