getting first node in xpath result set

Use the following: (//dl)[1] The parentheses are significant. You want the first node that results from //dl (not the set of dl elements that are the first child of their parent (which is what //dl[1] (no parens) returns)). This is easier to see when one realizes that // is shorthand for (i.e. expands fully to) … Read more

Best XPath tools [closed]

[Update] XMLQuire was originally recommended in this answer. It was a free XML editor for Windows with the SketchPath XPath Editor built in for XPath testing. XMLQuire has not been maintained for a few years and has now been retired. For XPath experimentation etc. XMLQuire’s author now recommends the XPath Notebook extension for Visual Studio … Read more

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

How to get a particular attribute from XML element in SQL Server

Try using the .value function instead of .query: SELECT xmlCol.value(‘(/container/param[@name=”paramB”]/@value)[1]’, ‘varchar(50)’) FROM LogTable The XPath expression could potentially return a list of nodes, therefore you need to add a [1] to that potential list to tell SQL Server to use the first of those entries (and yes – that list is 1-based – not 0-based). … Read more

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