XPath to select multiple tags

One correct answer is: /a/b/*[self::c or self::d or self::e] Do note that this a/b/*[local-name()=’c’ or local-name()=’d’ or local-name()=’e’] is both too-long and incorrect. This XPath expression will select nodes like: OhMy:c NotWanted:d QuiteDifferent:e

How to use XPath contains() here?

You are only looking at the first li child in the query you have instead of looking for any li child element that may contain the text, ‘Model’. What you need is a query like the following: //ul[@class=”featureList” and ./li[contains(.,’Model’)]] This query will give you the elements that have a class of featureList with one … Read more

How to parse XML in Bash?

This is really just an explaination of Yuzem’s answer, but I didn’t feel like this much editing should be done to someone else, and comments don’t allow formatting, so… rdom () { local IFS=\> ; read -d \< E C ;} Let’s call that “read_dom” instead of “rdom”, space it out a bit and use … Read more

XPath: select text node

Having the following XML: <node>Text1<subnode/>text2</node> How do I select either the first or the second text node via XPath? Use: /node/text() This selects all text-node children of the top element (named “node”) of the XML document. /node/text()[1] This selects the first text-node child of the top element (named “node”) of the XML document. /node/text()[2] This … Read more

XPath query to get nth instance of an element

This is a FAQ: //somexpression[$N] means “Find every node selected by //somexpression that is the $Nth child of its parent”. What you want is: (//input[@id=”search_query”])[2] Remember: The [] operator has higher precedence (priority) than the // abbreviation.

XPath OR operator for different nodes

All title nodes with zipcode or book node as parent: Version 1: //title[parent::zipcode|parent::book] Version 2: //bookstore/book/title|//bookstore/city/zipcode/title Version 3: (results are sorted based on source data rather than the order of book then zipcode) //title[../../../*[book] or ../../../../*[city/zipcode]] or – used within true/false – a Boolean operator in xpath | – a Union operator in xpath that … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)