Getting element’s name in XPATH

Use name(). (Find docs for newer versions of the XPath language here.) Here are modified versions of your example: Works in XPath 2.0+ only: //element/*[@id=’elid’]/name() Works in XPath 1.0 and 2.0+*: name(//element/*[@id=’elid’]) *If using 2.0+, the expression //element/*[@id=’elid’] must only return one element. Otherwise you’ll get an error like A sequence of more than one … Read more

What’s the difference between //node and /descendant::node in xpath?

see http://www.w3.org/TR/xpath#path-abbrev // is just an abbreviation for the descendant:: axis Edit To quote: //para is short for /descendant-or-self::node()/child::para That is, it refers to all para which are a child of the context node or any node descended from the context node. As far as I can tell that translates into any descendant para of … Read more

Difference between text() and string()

Can someone explain the difference between text() and string() functions. I. text() isn’t a function but a node test. It is used to select all text-node children of the context node. So, if the context node is an element named x, then text() selects all text-node children of x. Other examples: /a/b/c/text() selects all text-node … Read more

XPath find text in any text node

This expression //text() = ‘Alliance Consulting’ evals to a boolean. In case of this test sample: <r> <t>Alliance Consulting</t> <s> <p>Test string <f>Alliance Consulting</f> </p> </s> <z> Alliance Consulting <y> Other string </y> </z> </r> It will return true of course. Expression you need should evaluate to node-set, so use: //text()[. = ‘Alliance Consulting’] E.g. … Read more

Only select text directly in node, not in child nodes

In the provided XML document: <div id=”comment”> <div class=”title”>Editor’s Description</div> <div class=”changed”>Last updated: </div> <br class=”clear”> Lorem ipsum dolor sit amet. </div> the top element /div has 4 children nodes that are text nodes. The first three of these four text-node children are whitespace-only. The last of these 4 text-node children is the one that … Read more

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