xpath

Using Variable and XPATH to select value of element

Hi, I have the following snipset of code <xsl:variable name="cId" value="c001" /> <clients> <c001>Mario</c001> <c002>Luigi</c002> </clients> And Based on variable's value, I need to select the correct element under clients. For Example. variable cId is assigned with value c001. Is there a way for me to select the value of ...

How to retrieve XML data using XPath Expression

I have a XMLDataSource somewhat like: <bookstore> <author>author1</author> <publication>publication1</publication> <book> <genre>Thriller</genre> <name>ABC</name> </book> <book> <genre>Romance</genre> <name>XYZ</name> </book> <book> <genre>Horror</genre> <name>000</name> </book> </bookstore> I a...

path to element with conditions on parent(s) attributes using xpath,lxml,python

Hello I am working on project using lxml. here is a sample xml <PatientsTree> <Patient PatientID="SKU065427"> <Study StudyInstanceUID="25.2.9.2.1107.5.1.4.49339.30000006050107501192100000001"> <Series SeriesInstanceUID="2.16.840.1.113669.1919.1176798690"/> <Series SeriesInstanceUID="2.16.840.1.113669.1919.117708...

[XSLT] Position() and Issues with the value I am retrieving

<tableLayout> <tableColumn width="250"/> <tableDivider spaceAfter="0" spaceBefore="0"/> <tableColumn/> <tableDivider spaceAfter="0" spaceBefore="0"/> <tableColumn/> </tableLayout> When selecting the width for the current "column" using the above data (not my decision to structure it like this...

Select some but not all child nodes

I have the following XML structure: <?xml version="1.0" encoding="ISO-8859-1"?> <articles> <article id="1"> <title>Article title 001</title> <short>Short text</short> <long>Long text</long> </article> <article id="2"> <title>Article title 002</title> <short>Short text</short> <long>Long text</long> </arti...

Using XSLT Apply-Templates to conditionally select nodes

Let's say I have an xml document like this: <director> <play> <t>Nutcracker</t> <a>Tom Cruise</a> </play> <play> <t>Nutcracker</t> <a>Robin Williams</a> </play> <play> <t>Grinch Stole Christmas</t> <a>Will Smith</a> </play> <play> <t>Grinch Stole Christm...

Xpath best practices

Hello there, I have a readonly xml file and I have a set of xpath values. I need to create a function which would take in the xpath and return the value(s) corresponding to the xpath. I am a little confused regarding what would be the best way to proceed. The options I am thinking are using the regular XPathDocument/Navigator/Iterator ...

Get first few elements of a html fragment with xpath on ruby

For a blog like project, I want to get the first few paragraphs, headers, lists or whatever within a range of characters from a markdown generated html fragment to display as a summary. So if I have <h1>hello world</h1> <p>Lets say these are 100 chars</p> <ul> <li>some bla bla, 40 chars</li> </ul> <p>some other text</p> And assum...

max value of attribute

I want to change the values of the @page attributes of <line/> that are descendants of <section type="cover"/> to (max(@page) + 1) of <section type="contents"/>. Basically I need the page number for the cover section to be 1 higher than the last numeric page number of the contents section. Note: <line/> nodes are not always siblings, ...

Select top 10 events from wevtutil using xpath

I am currently working on a project that uses the Windows event log. I am using wevtutil to get the results from the event logs. I know that wevtutil supports xpath queries, but since I'm new to xpath I don't know that I can achieve what I'm trying to do. In SQL, what I would be doing is something like this: SELECT log.*, COUNT(1) numH...

XPath expression for selecting all nodes with a common attribute

Hi, a book I'm reading on XML says that to select all nodes in an XML file that have a specific attribute, use the syntax: //*/@attribute What I don't understand is why the asterisk is needed. As I understand it, the expression // selects all descendants of the root node. So, wouldn't //@lang, for example, select all descendants of th...

Selenium Click method not working on an Xpath locator

Folks, My first time on Stack Overflow. Hope y'all can help ... I'm trying to use Selenium to click on the 'Buy Now' button on an html page. Here's the HTML snippet: </div> <a href="javascript:void(0)" class="buttonCheckout">Buy Now</a> <a href="#" class="buttonSoldout">Sold Out</a> </div> I used the Selenium IDE to get the ...

XPath query to get nth instance of an element

There is an HTML file (whose contents I do not control) that has several input elements all with the same fixed id attribute of "search_query". The contents of the file can change, but I know that I always want to get the second input element with the id attribute "search_query". I need an XPath expression to do this. I tried //input[@i...

XST - using output from call-template as return value

Suppose i have a template foo which can output something given a parameter. Now I want to use that output as a parameter to my other template, loop so I can loop the output a certain number of times. I have tried something along the way of <xsl:call-template name="loop"> <xsl:with-param name="times" select="someParam"/> ...

Regular Expressions (HTML parsing on iPhone)

Hello, I am trying to pull data from a website using objective-c. This is all very new to me, so I've done some research. What I know now is that I need to use xpath, and I have another wrapper for that called hpple for the iPhone. I've got it up and running in my project. I am confused about the way I retrieve information from th...

DOMXpath | Select the innermost divs

Im looking for a way to select the innermost div with PHP for example: <div> <div> <div> - </div> </div> <div> <div> <div> - </div> </div> </div> </div> The DIV's containing the - would be selected in the NodeList Im using DOMDocument...

HtmlAgilityPack with XPath - retrieve nodes that doesn't contain &nbsp;

I'm trying to retrieve a select amount of elements that doesn't contain the value &nbsp; (a space) using the HtmlAgilityPack in C#. Here's my XPath expression: "(td)[(position() >= 10 and position() <= last()) and not(.='&nbsp;')]" but it is still giving me these nodes, I've tried using a literal space, &#160; ALT + 1060 - nothing see...

xpath not working as expected

From comments I found the issue :(, Thank you so much for your help, its appreciated, the reason's was because error reporting was switched off and then there was a missing function, causing the script to stop executing in its place For some reason this Xpath query is not working as expected foreach($this->Xpath->query...

XPath and Jabber-RPC

I'm trying to access the methodName element of an XML document using XPATH in Cocoa via the NSXMLElement object. This is the XML representation of element <iq type='set' from='[email protected]/jrpc-client' to='[email protected]/jrpc-server' id='rpc1'> <query xmlns='jabber:iq:rpc'> <methodCall> <m...

SimpleXmlElement and XPath, getting empty array()

I am having a little trouble with parsing XML from a google checkout response. The XML is coming straight from the google server so there is no problem with the XML itself. I want to get hold of all the new-order-notification tags I tried this but get an empty array() returned everytime. $xml = new SimpleXmlElement($raw_xml); $notifi...