XPath is actually pretty useful once it stops being confusing
news.rapgenius.com
XPath is actually pretty useful once it stops being confusing
1–10 of 77 posts
Re: XPath is actually pretty useful once it stops being confusing
#2Re: XPath is actually pretty useful once it stops being confusing
#3I also like XPath for some purposes, but I think it really suffers from (IIRC) having been designed before the xml namespaces, which it only integrates very awkwardly IMO and which ruins the simplicity of XPath. Or maybe XML namespaces spoil everything they affect to some degree :)
In every single task I do that involves munching on XML with xpath, the largest timesink is figuring out how the ns needs to be set up. (Looking you you, PHP simpleXML).
Re: XPath is actually pretty useful once it stops being confusing
#4I also like XPath for some purposes, but I think it really suffers from (IIRC) having been designed before the xml namespaces, which it only integrates very awkwardly IMO and which ruins the simplicity of XPath. Or maybe XML namespaces spoil everything they affect to some degree :)
It's the latter (XML namespaces spoil everything). In every single task I do that involves munching on XML with xpath, the largest timesink is figuring out how the ns needs to be set up. (Looking you you, PHP simpleXML).
And more generally that's true of every single task involving muching on namespaced XML. Namespaces are a good idea implemented absolutely terribly.
XPath is a good idea well-implemented (no, XPath 2 does not exist, there is only one XPath). One of the few I've found in XML-land. I still hate that we have to use CSS selectors rather than XPath (although that's understandable considering CSS selectors predate XPath), most of the improvements since CSS1 were in XPath day 1, and the rest (pseudo-classes) could probably have been implemented using functions.
Also, that might have finally gotten us a non-eye-stabbing standard function for "match any item of a space-separated list in an attribute" (matching HTML classes in XPath without custom helpers is the worst)
Re: XPath is actually pretty useful once it stops being confusing
#5The `/` in an XPath expression is probably a better match for the space in CSS selectors.
Re: XPath is actually pretty useful once it stops being confusing
#6Re: XPath is actually pretty useful once it stops being confusing
#7Earlier quoted context omitted.
It's the latter (XML namespaces spoil everything). In every single task I do that involves munching on XML with xpath, the largest timesink is figuring out how the ns needs to be set up. (Looking you you, PHP simpleXML).
> In every single task I do that involves munching on XML with xpath And more generally that's true of every single task involving muching on namespaced XML. Namespaces are a good idea implemented absolutely terribly. XPath is a good idea well-implemented (no, XPath 2 does not exist, there is only one XPath). One of the few I've found in XML-land. I still hate that we have to use CSS selectors rather than XPath (alth…
Re: XPath is actually pretty useful once it stops being confusing
#8And that is what I've found most people who have trouble with it don't understand - like what exactly following-sibling or child means.
I spent about 2 months writing my own xpath evaluator once and it gets so much easier (to implement too) when you understand this is just a tree-traversal with an iterator following the axis.
Unfortunately the axis syntax makes it very verbose to read.
Re: XPath is actually pretty useful once it stops being confusing
#9> the / in an XPath expression plays the same role as the > in a CSS selector: The `/` in an XPath expression is probably a better match for the space in CSS selectors.