xpath

XPath query to select all href attributes of <a> tag, which 'class' attribute equals specified string

I don't know why following query doesn't work: //a/@href[@class='specified_string'] ...

Xpath Query to match immediate sibling nodes in a sequence.

Hi, I'm new to XPATH and I'd like to know if there is a nice way to do this using XPATH queries. I want to match consecutive sibling nodes in a XML tree to certain predefined rules for example if there are three sibling nodes occurring immediately one after the other and they have the attributes value="A", value="B" and value="C", I w...

Removing duplicate values from dataset

I want to print only unique values from a dataset into the list component, avoiding duplicate values. How do I do it ? Please help. ...

Test first subnode from node.

XML: <mode> <submode>1</submode> <submode>2</submode> <submode>3</submode> <submode>4</submode> <submode>5</submode> <submode>6</submode> <submode>7</submode> </mode> <mode> <submode>7</submode> <submode>8</submode> <submode>9</submode> <...

XSL apply templates not working...could be XPath error

I have converted mny stylesheet to use apply templates instead of call templates and it worked fine for my other styesheet, which was more complicated, but this one doesn't seem to work even thought it is a much simpler template. All that it outputs is the sex node and the userlevel node. I think it has to do with my Xpath. All i want...

document.evalute function giving exception

I have a code like res = doc.evalute(xpathExpr,doc, function(prefix) {return namespaces[prefix] || null;}, XPathResult.ANY_TYPE,null ); Here doc is DOM document node When i run for loop like this for(i in doc) alert(i); it gives evaluate method but when i tried to use this method on dom node ...

webBrowser1.Document.MouseOver in .net to get XPath to the object in IE6

I'm doing test automation with Selenium and have now ended up testing an old .NET 1.1 app that only runs in IE6 that is kind of semi-ajax. Most of the objects does not have any ID tags etc and this complicates things writing the scripts. Now I'm trying to make my own little selenium-recorder for IE6 and I have made a small C# .Net proje...

XPath and special characters

I am having an issue with an XPath query I'm performing for a Sitecore CMS system. This query works fine: /root/content/Meta-Data/Tips/* But when I try this: /root/content/Meta-Data/Tips/*[@SomeAttribute='somekey'] I get an error which says "End of string expected at position 22" which is where the dash character is found. I was un...

Can I use XPath to filter elements by CSS properties?

Or do I have to do something like this: var nodes = document.childNodes; for (var i in nodes) { if (window.getComputedStyle(nodes[i], null).getPropertyValue('someproperty') == 'somevalue') // do stuff } Edit: I'm not very familiar with XPath. A 'simple' stab at the problem would be something like this: function test() { ...

Removing related elements using XSLT 1.0

I'm attempting to remove Component elements from the XML below that have File children with the extension "config." I've managed to do this part, but I also need to remove the matching ComponentRef elements that have the same "Id" values as these Components. <Fragment> <DirectoryRef Id="MyWebsite"> <Component Id="Comp1"> <Fi...

Using Xpath to retrieve nodes satisfying a certain criteria, based on attribute values

<AgoraServersConfig> <AgoraServers id="NYQ1"> <AgoraName>prod</AgoraName> <TableName>someTable</TableName> <Rule_ID>1</Rule_ID> <Rule_ID>3</Rule_ID> <Rule_ID>5</Rule_ID> </AgoraServers> <AgoraServers id ="QA03"> <AgoraName>dev</AgoraName> <TableName>someTable</TableName> <Rule_ID>1</Rule_ID> <Rul...

JUnit Test if XML Document is sorted on arbitrary column

Given an xml document like <root> <row> <a>2</a> <b>1</b> <c>8</c> </row> <row> <b>5</b> <a>2</a> <c>8</c> </row> <row> <a>2</a> <c>8</c> <b>6</b> </row> </root> Is there an easy way to assert that the XML document is sorted on element B in XMLUnit Edit: I have an odd problem with a pie...

jQuery - xpath find?

If you have the xml below in $(xml), you would get droopy using: $(xml).find("animal").find("dog").find("beagle").text() Is there an equivalent way in jQuery to use xpath like $(xml).xpathfind("/animal/dog/beagle").text()? <animal> <dog> <beagle> droopy </beagle> ... ...

Xpath help function

Hi i have a document from which i am trying to extract a date. But the problem is within the node along with the date their is some text too. Something like <div class="postHeader"> Posted on July 20, 2009 9:22 PM PDT </div> From this tag i just want the date item not the Posted on text. something like ./xhtml:div...

xpath help substring expression

Hi i have a document from which i am trying to extract a date. But the problem is within the node along with the date their is some text too. Something like <div class="postHeader"> Posted on July 20, 2009 9:22 PM PDT </div> From this tag i just want the date item not the Posted on text. something like ./xhtml:div[@...

Selecting unique elements using XSLT.

I have the following XML: <option> <title>ABC</title> <desc>123</desc> </option> <option> <title>ABC</title> <desc>12345</desc> </option> <option> <title>ABC</title> <desc>123</desc> </option> <option> <title>EFG</title> <desc>123</desc> </option> <option> <title>EFG</title> <desc>456</desc> </opt...

XPath select certain amount of levels only

If I have an xml structure like this <root> <sub> <node /> <node /> </sub> <sub> <node /> <sub> <sub> <sub> <node /> </sub> </sub> <sub> <sub> <sub> <node /> </sub> <node /> </sub> </sub> <node /> <node /> </root> Is there an xpath syntax which will...

trouble finding element on page using xpath or css

Guys, I'm trying to write xpath or css to find/click on list element "All" based on known span(in this case SNG NAME below). On page, there are different lists Which can contain same list item called as "All". So we have to identify "All" based on span(in this case SNG NAME below) can someone shed some light on my issue <html> <head>...

How to set an empty value using XPath?

Using this xml example: <templateitem itemid="5"> <templateitemdata>%ARN%</templateitemdata> </templateitem> <templateitem itemid="6"> <templateitemdata></templateitemdata> </templateitem> I am using XPath to get and set Node values. The code I am using to get the nodes is: private static Node ***getNode***(Document doc, String...

How can I get a value from an xml key/value pair with xpath in my xslt?

I have some xml that I want to process using xslt. A good amount of the data comes through in key value pairs (see below). I am struggling with how to extract the value base on the key into a variable. I would like to be able to do something like this: <xsl:variable name="foo" select="/root/entry[key = 'foo']/value"/> but that does...