xpath

selenium: a custom locator that uses xpath locator

I want to define a custom locator with selenium, and I want it to use the existing xpath locator. The code below does not work. How should I do it? PageBot.prototype.locateElementByNg= function(text, inDocument) { var xpath = doSomeManipulation(text); return PageBot.prototype.locateElementByXpath(xpath, inDocument); }; ...

Form to search XML document

I got a tutorial from W3CSchools on XML and XSL, I have three files (Please see code below) XML - cdcatalog.xml XSL - cdcatalog.xsl HTML - search.htm What Im trying to do is build a HTML search form to search the XML document, ive change some artist names within the XML file so for example if i did a search for Bob Dylan these three det...

Sanity Check with XPath in Ruby Watir

I'm using the Ruby Watir library to do automated testing for a client and I'm having issues with the XPath selector. I think I just need another set of eyes to let me know if I'm just missing something. Here is the selector I'm using: puts ie.cell(:xpath, "//img[@src='3.jpg']/../").text For this set of tables, it works as expected ...

XSL: Counting Previous Unique Siblings

OK, I want to apply a XSL style sheet that counts the previous unique "ROLE" nodes and spits out the following output format of @name the number of unique ROLE nodes prior to the current nodes. I've wasted several hours on what should be an easy thing to implement. I have tried to implement this in several ways including the Muenchian...

XPath query that respect node positon and attribute value

Is there a way to build a XPath query that finds a node at a certain position AND with a certain attribute value? Consider the following sample xml: <Item Type="Book"> <!--1st Param node in a Book item is always the autors last name--> <Param Value="Updike" /> <!--2nd Param node in a Book item is always the autors first name--> <Param ...

looping through items using xPath

I am tryng to loop through an xml doc and I am still getting the first element in the second iteration, not sure what I am missing. Can anyone help? Pretty new with Xpath string file = HttpContext.Current.Server.MapPath("~/XML/Locations.xml"); Dictionary<string, Location> locationCollection = new Dictionary<string, Location>(); ...

How can I use XSL to run a template against a specific node that is located by an attribute?

For example, I'm trying to pick out the value "Application Library" from the following XML - ie, the value under content-node/localedata/title, where localedata@locale = "en". <content-node objectid="6_NO2UF4I1186E1026H4BLVI08F1"> <localedata locale="de"> <title>Anwendungsbibliothek</title> </localedata> ...

How do you output the current element path in XSLT?

In XSLT, is there a way to determine where you are in an XML document when processing an element? Example: Given the following XML Doc Fragment... <Doc> <Ele1> <Ele11> <Ele111> </Ele111> </Ele11> </Ele1> <Ele2> </Ele2> </Doc> In XSLT, if my context is the Element "Ele111", how can I get XSLT to output the ...

How do I perform a case insensitive search for a node in PHP xpath?

I don't want a search for the string value to be case insensitive. I want to do a search for the node without regard for case sensitivity. If the XML looks like this: <items> <ITEM>My text!</ITEM> </items> I need something like this to work: $someXmlDoc->xpath("/items/item/text()"); Currently, only this works: $someXmlDoc->xpat...

Relative XPath node selection with C# XmlDocument

Imagine the following XML document: <root> <person_data> <person> <name>John</name> <age>35</age> </person> <person> <name>Jim</name> <age>50</age> </person> </person_data> <locations> <location> <name>John</name> ...

greasemonkey script that outputs all data corresponding to xpath

I would like to write a greasemonkey script that given an xpath returns all of the output of that xpath executed on the current page in a .txt file with one result per row. How do I do this? EDIT: Its ok if the output is not written to a file. I just want to have it displayed. ...

CDATA in XML using C#

This is an unusual situation. We are forced to interface with a 3rd party who requires certain values in the xml response to be wrapped with even if it is just a string value. Example: <Property name="someName" type="String"><![CDATA[someValue]]></Property> We are adding these property nodes to the document as follows: XPathExpressi...

extract xpath

I want to retrieve the xpath of an attribute (example "brand" of a product from a retailer website). One way of doing it is using addons like xpather or xpath checker to firefox, opening up the website using firefox and right clicking the desired attrbute I am interested in. This is ok. But I want to capture this information for many a...

XPath 1.0 max function on variables using EXSLT

Hi, I am serching an XPath function that works like the XPath 2.0 fn:max function. A function that returns the maximum of several parameters. After searching a lot I figured out this way: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:math="http://exslt.org/...

Working With Nested XPath Predicates ... Refined

All great answers! But the question deserves refinement ... I've got the following sample XML ... <objects> <object objectId="1123" ... /> <properties refObjectId="1123" ... /> <properties refObjectId="1123" refPropertyId="2311" ... /> <properties refObjectId="1123" refPropertyId="4611" ... /> <object objectId="212...

How to use XML::XPath to get parent node?

I want to parse XML files using xPaths. After getting a node I may need to perform xPath searches on their parent nodes. My current code using XML::XPath is: my $xp = XML::XPath->new(filename => $XMLPath); # get all foo or foos node with a name my $Foo = $xp->find('//foo[name] | //foos[name]'); if (!$Foo->isa('XML::XPath::NodeSet') ||...

Evaluating XPath Commands with java

Hi I have an xml document like this <root> <cert id="1"> </cert> <cert id="2"> </cert> <cert id="3"> </cert> </root> now I get a request and want to select the cert with id 2 and want to return it in a function. What is the best way to do this? I thought about XPAth Expression, how can I use them in java? What would be ...

Using XLink to refer to nodes within same document

The general gist of a simple XLink to another node in the same document seems to be: <root xmlns:xlink="http://www.w3.org/1999/xlink"&gt; <firstChild id="ID1" /> ... <ref xlink:href="#ID1" /> </root> Without using XPointer or XPath, is this as much as you can do with XLink? Could you do an XLink which, say, referred to a customI...

is there an "if -then - else " statement in xpath?

It seems with all the rich amount of function in xpath that you could do an "if" . However , my engine keeps insisting "there is no such function" , and I hardly find any documentation on the web (I found some dubious sources , but the syntax they had didn't work) I need to remove ':' from the end of a string (if exist), so I wanted to...

What is the difference between using "../" and "parent" in an XPath query?

What is the difference here between using "../" and "parent" to get the parent node in an XPath query. I had thought they were synonymous. Given the following two XPath queries is there really any difference between these two? //Node/id[@type='image']/id[@attr1='myVal']/../../* //Node/id[@type='image']/id[@attr1='myVal']/parent::*/pa...