XPath Conditionals On Subsets

I wanted to do a quick cross post from my personal blog over to here because I feel that the importance of this tidbit of information is something that should be common knowledge. However, most of us know that xpath is far from common knowledge despite the fact that XML is a part of our daily lives!

David Lanier, a co-conspirator on the store team asked me the question:

Why is it when I do //div[contains(@class,'views-field-name')][2] I'm not getting the second one?

I was like... that's a good question... let me see if I can figure out the answer. The following blog post is dedicated to our discussion and an explanation to WHY exactly [2] doesn't mean second node in the set.

Read more...

comments powered by Disqus