xpath

Selecting node sets (attributes or elements) which match a string variable name

Consider this simple xml element example: <parent foo="1" bar="2" foobar="3"> <child/> </parent> In the xsl file, I am in the context of "parent" (i.e. within the <template match="parent">). I want to select a node set (in the example, only one attribute) based upon a string variable. For example i want to select a node-set which ...

Selecting (siblings) between two tags using XPath (in .NET)

I'm using .NET 3.5 (C#) and the HTML Agility Pack to do some web scraping. Some fields that I need to extract are structured as paragraphs within which components are separated by line-break tags. I'd like to be able to select out the individual components between the line-breaks. Each component may be formed from multiple elements (i.e....

XPath with Yahoo API

I have been scratching my head trying to figure out how to use C#/XPath/SelectNodes to extract nodes from a Yahoo API XML result. I essentially have the same problem as stated under C# XmlDocument SelectNodes as well as under SelectNodes not working on stackoverflow feed The point I'm stuck on is understanding exactly what to use as t...

What XPath selects the next <tr> after a <tr> containing X?

<tr> <td>Blah!</td> <td>X</td> <!-- TR containing X --> <td>Woot!</td> </tr> <tr> <td>Useful Data, contents unknown</td> <!-- Select this TR --> </tr> <tr> <td>Useless data</td> <!-- Don't select this or any subsequent TR --> </tr> <tr> <td>More crap I don't want</td> </tr> <tr> <td>X</td> <!-- Another X --> </tr> <tr> <td>Useful...

XSLT: tricky transformation, need help!

hi! i have to build an XSLT stylesheet that transforms an xml like this: <message> <line/> <silence/> <dot/><line/><line/> <silence/> <dot/> <silence/> <line/><dot/><dot/><dot/> </message> into something like this: <complexMessage> <word code="-"/> <word code=".--"/> <word code="."/> <word code="-..."/> </compl...

Finding xmlns with xsl/xpath

I'm trying to obtain a list of information for the root element of an xml document using a transformation. The pieces I can't figure out are: How do I obtain the default namespace url? How can I obtain a list of every xmlns prefix and its related url? Here's my xml file: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="t...

How to train a team member to be the Xml Expert

Folks, I have got to work with a new team and design the required skills for each of them, I want to put a compressed training plan for one of them to be the Xml Expert in the team, as part of this I put him to read about XPath, XSLT from W3Schools, but what else he needs to know ? or is there a better source ? ...

How to apply a XSL template only on elements containing a child with a particular attribute value and element value ?

Hello, I have the following XML (partial) document : <export> <table name="CLIENT"> <row> <col name="CODE_CLIENT" type="System.String">1000010026</col> <col name="LIBELLE" type="System.String">Test|</col> <col name="PROSPECT" type="System.Decimal">1</col> </row> <row> <col name="CODE_CLIENT"...

XPath: How to select nodes which have no attributes?

Using XPath, how to select nodes which have no attributes (where attribute count = 0)? For example: <nodes> <node attribute1="aaaa"></node> <node attribute1="bbbb"></node> <node></node> <- FIND THIS </nodes> ...

how to create XPATH for a HTML DOM element?

Hi All, How to create XPATH for a HTML DOM element? for example, "/HTML/BODY/DIV[1]/TABLE[1]/TR[2]/TD[1]/INPUT". Given an DOM element how to get this XPATH string? Any ideas? Thanks, Dattebayo. ...

XSLT to sum product of two attributes

Hi All I have the following XML source structure: <turnovers> <turnover repid="1" amount="500" rate="0.1"/> <turnover repid="5" amount="600" rate="0.5"/> <turnover repid="4" amount="400" rate="0.2"/> <turnover repid="1" amount="700" rate="0.05"/> <turnover repid="2" amount="100" rate="0.15"/> <turnover repid="1"...

How to select the second node using xsl:for-each in the listed xml content?

Hi, I have a list of figure names and width and height informations in separate xml file, I need to match the figure name in the source xml file and need to insert the width and height information as a attribute in the source xml file. here the source xml file.. <graphic name="sample.jpg" align="center"/> expected output xml file ...

Xpathexpression AddSort on multilpe field ??

Hi, My application will process more than 10000 xml documents as batch. while processing I want to sort the content of xml documents. I came accross XpathExpression AddSort method, but how to use i to sort on multiple fields ? or using xslttranform will be appropriate ?? which is better in term of performance ?? Thanks in advance. Jon ...

Cannot install XML::LibXML module on Windows

I am trying to use XPath to extract some HTML tags and data and for that I need to use XML::LibXML module. I tried installing it from CPAN shell but it doesn't install. I followed the instructions from CPAN site about the installation, that we need to install libxml2, iconv and zlib wrappers before installing XML::LibXML and it didn't ...

does javascript on iphone mobile safari support xpath?

does javascript on iphone mobile safari support xpath? I am using libxml2 to parse xhtml files in objective-c, but want to be able to change my parsing logic on the fly. Was considering using UIWebview's stringByEvaluatingJavaScriptFromString: method. ...

How to transform an sequence attribute to single element in the necessary place?

I have to make the attribute into single element. Please guide me. Here my input and requirement. Input: <book pagenum="01"> <title pagenum="01">Book title</title> <chapter pagenum="02"> <chaptertitle pagenum="02">CHAPTER TITLE</chaptertitle> <section pagenum="03"> <sectiontitle pagenum="03">SECTION TITLE</chaptertitle> <subsection pa...

problems with xml output from C# webservice and/or xpath query

Hi! The webservice I've build returns XML by default, I added my own XML nodes which I need to query in a different application (Nintex). I do that with Xpath. But I can't seem to get the result I want... public class Service1 : System.Web.Services.WebService { public struct aduser { public String result; pu...

Clear Unwanted Namespaces with LibXML-Ruby

I would like to parse an Atom Feed and create an Atom-compliant cache of each Entry. The problem is that some feeds (this one for example) have many namespaces other than the Atom one. Is it possible to keep intact all Atom nodes and remove each node that belongs to another namespace? Something like this: valid_nodes = entry.find('a...

Special Character in XPATH Query

I use the following XPATH Query to list the object under a site. "ListObject[@Title='SomeValue']". SomeValue is dynamic. This query works as long as SomeValue does not have an apostrophe ('). I use C#. Tried using escape sequence also. Didn't work. What am I doing wrong? ...

XPath: How to select the first given parent of a node?

My XML: <root> <child> <childOfChild> <anotherLostChild> <currentSelectedNode> SOME TEXT </currentSelectedNode> </anotherLostChild> </childOfChild> </child> </root> I selected the node currentSelectedNode using: xpath.SelectSingleNode("//currentSelectedNode") But How...