What is the correct XPath for choosing attributes that contain “foo”?

//a[contains(@prop,’Foo’)] Works if I use this XML to get results back. <bla> <a prop=”Foo1″>a</a> <a prop=”Foo2″>b</a> <a prop=”3Foo”>c</a> <a prop=”Bar”>a</a> </bla> Edit: Another thing to note is that while the XPath above will return the correct answer for that particular xml, if you want to guarantee you only get the “a” elements in element “bla”, … Read more

How to execute XPath one-liners from shell?

You should try these tools : xmlstarlet (xmlstarlet page) : can edit, select, transform… Not installed by default, xpath1 xmllint (man xmllint): often installed by default with libxml2-utils, xpath1 (check my wrapper to have –xpath switch on very old releases and newlines delimited output (v < 2.9.9)). Can be used as interactive shell with the … Read more

XPath to select Element by attribute value

You need to remove the / before the [. Predicates (the parts in [..]) shouldn’t have slashes immediately before them – they go directly after the node selector they are associated with. Also, to select the Employee element itself, you should leave off the /text() at the end. Otherwise you’d just be selecting the whitespace … Read more

How to verify an XPath expression in Chrome Developers tool or Firefox’s Firebug?

Chrome This can be achieved by three different approaches (see my blog article here for more details): Search in Elements panel like below Execute $x() and $$() in Console panel, as shown in Lawrence’s answer Third party extensions (not really necessary in most of the cases, could be an overkill) Here is how you search … Read more

XPath: Get parent node from child node

Use the parent axes with the parent node’s name. //*[title=”50″]/parent::store This XPath will only select the parent node if it is a store. But you can also use one of these //*[title=”50″]/parent::* //*[title=”50″]/.. These xpaths will select any parent node. So if the document changes you will always select a node, even if it is … Read more

XPath to select element based on childs child value

Almost there. In your predicate, you want a relative path, so change ./book[/author/name=”John”] to either ./book[author/name=”John”] or ./book[./author/name=”John”] and you will match your element. Your current predicate goes back to the root of the document to look for an author.

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