xpath

Use Xpath to find the appropriate element based on the element value

I have the following xml snippet <ZMARA01 SEGMENT="1"> <CHARACTERISTICS_01>X,001,COLOR_ATTRIBUTE_FR,BRUN ÉCORCE,TMBR,French C</CHARACTERISTICS_01> <CHARACTERISTICS_02>X,001,COLOR_ATTRIBUTE,Timber Brown,TMBR,Color Attr</CHARACTERISTICS_02> </ZMARA01> I am looking for an xpath expression that will...

xPath: select following-sibling and self nodes

Hello, From this piece of HTML: <tbody> <tr> <tr id="1" class="first"> <tr id="2" class=""> <tr id="3" class="last"> <tr id="4" class="first"> <tr id="5" class=""> <tr id="6" class="last"> <tbody> I´m trying to get an xPath expression to return all tr[@class='first'] nodes followed by tr which don´t have a...

Getting the following sibling in an XPath when "following" axis is not supported.

I am trying to get the text elements of a table that follows a paragraph that contains a specific text element using XQuery on MS SQL Server. The problem is whenever I use the axes "following", "following-sibling" or "previous-sibling", I get an error saying this is not supported in SQL Server (I'm using version 2008). So for instance,...

case insensitive xpath searching in php

I have an xml file like this: <volume name="Early"> <book name="School Years"> <chapter number="1"> <line number="1">Here's the first line with Chicago in it.</line> <line number="2">Here's a line that talks about Atlanta</line> <line number="3">Here's a line that says chicagogo </line> </chapter> </book> </volume> I'm trying to do a ...

How can I insert element into xml after/before certain element in java

Here is my code, maybe you will notice right away what I'm missing : DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = domFactory.newDocumentBuilder(); Document doc = builder.parse(fileName)); XPathFactory fact...

XPath class resolution in JBoss5

Dear all, I'm having a hard time figuring out where the problem is coming from, so I'm posting this in the hopes that others might have found something similar to this elsewhere and are kind enough to share their insight. I'm using a JBoss 5.0.1.GA application server running on top of a Sun Java 1.6.0-13 JDK. For the WAR file in the ge...

C# XPathNavigator returns string of all values instead of values

I have XML document which is something like <X><Y><Values><double>1.0</double><double>2.0</double></Values>... I am trying to get those values: toXpath.MoveToRoot(); // the X node name could be different toXpath.MoveToFirstChild(); // this should be Y string q = "Y/Values"; foreach (XPathNavigator x in toXpath.Select(q)) In x.Val...

is numerical and is alpha/numerical in XPath or XSL

Hi! I am wondering if it is possible to use XPath or XSL to determine if a XML node value is numerical or alpha/numerical. (It is user entered data.. so it could be either..) I was searching for some sort of function in XPath to do this.. but I couldn't find any. for example: <example> <test1 attribute="123">12dfffg23</test1> ...

Applying templates to elements in a variable/sequence

When I use "apply-templates" and select a variable sequence, does the template act upon the context of the element in the sequence, or does it act upon the context of the element in the document? In the below example, it seems to do either, or none, but I don't understand why. <root> <a/> <b/> <c><a/></c> <a/> </root> <?xml version="...

Is there a way to correctly concatenate two arbitrary XPath expressions to result in a new valid XPath expression?

I'm looking for a way to concatenate two arbitrary, valid XPath expressions to build a new XPath expression. Effectively I'd like to apply the second XPath expression on the result of the first XPath expression. For example, take this XML: <foo> <bar> <baz /> </bar> <foo> The XPath expression /foo would obviously return the ...

how to access this element

I am using Watir to write some tests for a web application. I need to get the text 'Bishop' from the HTML below but can't figure out how to do it. <div id="dnn_ctr353_Main_ctl00_ctl00_ctl00_ctl07_Field_048b9dfa-bc64-42e4-8bd5-b45385e5f45b_view" style="display: block;"> <div class="workprolabel wpFieldLabel"> <span title="Please s...

CreateNavigator (X-Path has invalid token)

Hi, I am trying to enumerate all the namespaces in a document using XPath. The following works in xmlspy, but not in .NET //*/namespace-uri(.) // Executing this in linqpad, I get the error below. xml.CreateNavigator().Select("//*/namespace-uri(.)").Dump(); // the error below. XPathException: ('//*/namespace-uri(.)' has an invalid toke...

modifying xml document using php

hello everyone , i have an xml file "Machine.xml" it contains: <Parameter name="host" value="localhost"/> <Parameter name="port" value="5900"/> i would like to change both parameters values using a php script... how can i do that? i mean i want the script to change host's value for example to : value="7.3.4.5" and port value to...

Select a row based on the contents of a cell with xpath

I have a table that consists of multiple rows that each contain 5 cells, like this: <tr> <td></td> <td>123456</td> <td>statusText</td> <td><a>linkText</a></td> <td>editButton</td> </tr> The 123456 could be any string of random letters and numbers. I want to be able to select a link based on the contents of the sec...

XPath: how to sort a nodeset obtained by an expression using an expression?

I have a group with the following attributes: <mygroup> <item id="0"> <item id="1"> <item id="2"> </mygroup> when I cal the expression /mygroup/item I need to re-order the nodeset according the attribute "id", there is a way to do it without using the sort template? ...

Extract XML info from feed ?

I try to extract specific data from an xml feed that comes from youtube. XML link: http://gdata.youtube.com/feeds/api/videos/WFPnl8aEPgo?alt=rss I've been able to extract info like: Title, Description using this query string: Dim Title As String = videoInfoNavigator.SelectSingleNode("/item[1]/title").Value However, I'm not ab...

How to iterate through DOM elements that match a css class using xpath?

I'm processing an HTML page with a variable number of p elements with a css class "myclass", using Python + Selenium RC. When I try to select each node with this xpath: //p[@class='myclass'][n] (with n a natural number) I get only the first p element with this css class for every n, unlike the situation if I iterate through selectin...

XPath Query Help

<?xml version="1.0" encoding="ISO-8859-1"?> <users> <user number="0775547857"> <step stepnumber="1">complete</step> <step stepnumber="2">complete</step> <step stepnumber="3">complete</step> </user> <user number="0775543754"> <step stepnumber="1">complete</step> <step stepnumber="2">complete</step> </user> <user number=...

XPath (c#) Selecting nodes, then further selecting nodes based on the first query

Hello, I have the following XML <question> <questiontext>How old are you?</questiontext> <options> <option oldScore="0" Score="20">17-25</option> <option oldScore="8" Score="12">26-30</option> <option oldScore="20" Score="2">31-50</option> <option oldScore="16" Score="10">51-60</option> <option...

php xpath dealing with apostrophe / single quote in searched text

In my PHP script, I'm using XPATH to search nodes for text. Everything works swimmingly -except - when I search for a word with an apostrophe. basically my code looks like this $keyword = $_GET['keyword']; ...snip... $xml = simplexml_load_file($data); $search = strtolower($keyword); $upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $lower =...