xpath

Selenium RC Having problems with XPath

Hi, I'm using Selenium RC with chrome-mode for Firefox to automate test cases for a web application. I'm writing the scripts in Java using TestNG framework and Eclipse. Now to the main point: I'm having problems with Selenium RC for recognizing certain XPaths. I validate my XPaths with XPath-Checker extension for Firefox which shows no...

using xpath get the correct value in selectName

Below I have written the code. I need help to get the right value in selectName. I am new to XPath. Basically with this code I am trying to achieve if employeeName = Chris I need to return 23549 to the calling function. Please help. Part of the code: public static string getEmployeeeID(string employeeName) { Cache cache = HttpC...

Getting elements in the order they appear in the document

I have a document and want to extract a couple of elements which ar direct descendents of the parent element but leave out others. The problem is that I don't get the elements in the order they appear in the document. The reason might actually be that the CSS selector I am using is wrong... require 'rubygems' require 'nokogiri' require ...

xpath query in c# throwing exception

I am trying to extract information from the following xml: ezb XmlDocument doc = new XmlDocument(); doc.Load("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"); var x = doc.SelectSingleNode("//@time"); labelDate.Text= "Data From: " + x.Value; works just fine! what does not work however and as far as I can tell the xpath-s...

Get element text from xml doc

Hi, I'm trying to extract some information from an online xml weather resource (weather underground). I am able to open the resource and pull out the desired elements, but what I really want is to return the element text as a variable, without the containing xml element tags, so I can manipulate it and display it on a web page. Perhap...

Matching only one of many unknown nodes with xpath

Hello. Im trying to match only one of each node with a generic match. Can this be done generic at all? I would have prefered to just match one of each node with the same local-name() <xsl:variable name="xmltree"> <node /> <anothernode /> <node /> <anothernode /> <unknown /> <anothernode /> <node /> <unknown /> </xsl:var...

XPath - select child of $var

Hello there, I'm trying to print all the <title> and <description> elements of an RSS 2.0 feed in a list using PHP. I could simply get these elements using: $rss->xpath('rss/channel/item/title | rss/channel/item/description') but I want to use it a little different. I want to use PHP to iterate through all the <item> elements using a f...

XPath : Get nodes where child node contains an attribute

Suppose I have the following XML: <book category="CLASSICS"> <title lang="it">Purgatorio</title> <author>Dante Alighieri</author> <year>1308</year> <price>30.00</price> </book> <book category="CLASSICS"> <title lang="it">Inferno</title> <author>Dante Alighieri</author> <year>1308</year> <price>30.00</price> </book> <b...

Search in xpath

Suppose this is the xml: <lib> <books type="paperback" name="A" /> <books type="pdf" name="B" /> <books type="hardbound" name="A" /> </lib> What will be the xpath code to search for book of type="paperback" and name="A"? TIA. Currently my code looks like this: import org.w3c.dom.*; import javax.xml.xpath.*; import javax.xml.parse...

XPath: "Exclude" tag in "InnerHtml" (<a href="">InnerHtml<span>excludeme</span></a>

Hi, I am using XPath to query HTML sites, which works pretty good so far, but now I hit a (brick)wall and can't find a solution :-) The html looks like this: <ul> <li><a href="">Text1<span>AnotherText1</span></a></li> <li><a href="">Text2<span>AnotherText2</span></a></li> <li><a href="">Text3<span>AnotherText3</span></a></li> </ul> ...

XSLT getting last element

Hello, I am trying to find the last element in my xml, which looks like <list> <element name="A" /> <element name="B" > <element name="C" /> <element name="D" > <element name="D" /> <element name="E" /> <element name="F" /> <eleme...

XPath Query Question

Given the following XML Snippet <Events> <Event> <DateTime>22.09.2009 11:27:18</DateTime> <EventType>Download</EventType> </Event> What is the XPath query to return all Events created today of type download? ...

XPath strangeness

I'm writing a script which reads and manipulates a KML (xml) document. Below is a snippet of the document I'm reading: <?xml version="1.0" encoding="UTF-8"?> <!-- Generated by Feature Manipulation Engine 2009 (Build 5658) --> <kml xmlns="http://earth.google.com/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"&gt; <Document> ...

Selenium RC Having problems with XPath for a table

I'm trying to select an element given by: /html/body[@id='someid']/form[@id='formid']/div[@id='someid2']/div[@id='']/div[@id='']/div[@id='']/table/tbody[@id='tableid']/tr[7]/td[2] Now the html of that row I'm trying to select looks like this: <tr> <td class="someClass">some text</td> <td class="someClass2">my required text for verif...

Known xpath 2.0 processor with jdom support

Which xpath 2.0 processors with jdom support are known? ...

template based on element attribute with different namespaces

I am looking for a match on template to process the XML, my XML file looks like <root xmlns="urn:nampespace1" xmlns:xsi="urn:namespace2"> <time xsi:type="IVL"> <low value="19990101"/> <high value="20000223"/> </time> <obs> <time xsi:type="PIVL"> <period value="9" unit="h"/> </time> </obs> </root> ...

Can I select DOM nodes with XPath attribute patterns using jQuery?

I've got a little problem: I don't know whether it is possible to select all DOM nodes with some attribute patterns using jQuery. For example, I need to select all nodes with id attribute set to a string starting with "_dom". I've found something like this: $("input[name^='news']").val("news here!"); but as far as I can see, this c...

Modify XPath to return second of two values

I have an XPath that returns two items. I want to modify it so that it returns only the second, or the last if there are more than 2. //a[@rel='next'] I tried //a[@rel='next'][2] but that doesn't return anything at all. How can I rewrite the xpath so I get only the 2nd link? ...

find all duplicate values in an element attribute

I have an xml document that is stored in sql server 2005 that I want to find all duplicate values from an id attribute within an xml element. The xml looks like this: <?xml version="1.0" encoding="utf-8"?> <session sessionValue="" id="ID-1"> <data id="ID-3"> <id>d394E6FF844734CB9A5E8B17612DC050A</id> <TotalResult>803</Tot...

How to access element using Watir and XPath

I have some HTML that looks like this: <h1 id="header">Header</h1> I would like to click it using Watir and XPath. ...