xpath

Searching an XML and getting a subset of the nodes as an XML

Given a search term, how to search the attributes of nodes in an XML and return the XML which contains only those nodes that match the term along with their parents all the way tracing to the root node. Here is an example of the input XML: <root> <node name = "Amaths"> <node name = "Bangles"/> </node> <node name = "C"> ...

XPath Query always returns NULL only on some queries in SingleNodeSelect

<?xml version="1.0" encoding="utf-16"?> <users> <user number="0772247157"> <step stepnumber="1">complete</step> <step stepnumber="2">complete</step> <step stepnumber="3">complete</step> </user> <user number="0772247158"> <step stepnumber="1">complete</step> <step stepnumber="2">complete</step> </user> <user ...

lookup nodes with xpath in java

Can anybody suggest how can I solve this, there is XML document that I'm trying to append. I'm looking up nodes with xpath, the things is the software which generates this XML sometimes screws it up as following : <element name="Element ">Element value</element> So when I'm looking the node up with xpath using //element[@name="Element...

How to convert default mysql modtimes into UTC date time using xslt

I need to convert default mysql modtimes into UTC formated datetimes using xslt. I have an xml document that contains dates that originated as mysql modtimes in the format: 2010-06-30 15:20:43.0 They are now in an xml document within an element "datestamp" 2010-03-16 13:52:56.0 In order to be published via an oai-pmh feed they need to...

python/xpath guru issue?

hi. using python 2.4/2.5, with libxm2dom. trying to get my haed around a question/issue that I'm considering. I have a doc I import the doc, and can build the DOM (libxml2dom) I'm trying to figure out if there's a way to programatically "search" for a given term, and be able to craft the XPath function to extract the href for the te...

How can I get the value of an HTML element using PHP and XPath?

I have a whole HTML string that is being evaluated using PHPDom and it's working perfectly, except I don't know how to do this one thing that seems really basic. I need to select an HTML element via XPath and have that element's content returned as a string. So far, this is what I have. Can anyone point me in the right direction as to ho...

XPath boolean 'or'

I'd like to select a node if it has class="something" or class="else". How can I do that? XPath docs don't seem to contain any easy to find boolean or equivalent. ...

How to place if condition based on attribute value within for-each loop

I have a loop in xsl and depending upon the attribute value, i want to write some text. XML is as follows: <ROWS><ROW oid="28439"><EFL eid="8" fid="27672" count="2"> <MK id="3" val="0"/> <MK id="11" val="0578678 "/> </ROW></ROWS> XSL is as follows: <xsl:for-each select="EFL/MK"> <xsl:value-of select="@id" />: ...

Parsing a blogspot XML file with Nokogiri

I have a blogspot exported xml file and it looks something like this: <feed> <entry> <title> title </title> <content type="html"> Content </content> </entry> <entry> <title> title </title> <content type="html"> Content </content> </entry> </feed> How do I parse with Nokogiri and Xpath??? Here is what I have : #!/usr/bin/env ruby r...

Parse XML from String using XPath in Bada?

I have read the tutorial on XML parsing in Bada. But I don't want to use a file. I need to parse my XML from a Osp::Base::String. Any ideas which methods should I use? So far I have replaced xpathCtx = xmlXPathNewContext(doc); if(xpathCtx == NULL) { AppLog("Error: unable to create new XPath context"); xmlFreeDoc(doc); return(E...

XPath select an image by classname

Hi, I have an xml sheet with some data and some images that i want to collect only a part using xslt. However, there is one image with a particular classname that i would like to collect especially. For example, the xml says: <img class="itemImage" height="130" src="image.png" width="195"/> How do I get the src attribute of this im...

VBScript: XPath Query with multiple namespaces

What XPath query should I use to get to the GetLogisticsOfferDateResult Node? I have attached the vbscript that I'm using. I suspect the problem has to do with the multiple namespaces in the document. But how do I reference the second namespace in the XPath? Dim responseXML responseXML = '"<s:Envelope xmlns:s=""http://schemas.xmlsoap.o...

Getting exact datapath of a treeview node

I am binding a Treeview to an XMLDataSource, The databindings are being generated automaticaly, The XML looks like this:- < Passengers> <Passenger type="normal" ethnic="asian"> <PassengerName>Name1</PassengerName> </Passenger> <Passenger type="normal"> <PassengerName>Name2</PassengerName> </Passenger> <Passenger> ...

Xpath php fetch links

I'm using this example to fetch links from a website : http://www.merchantos.com/makebeta/php/scraping-links-with-php/ $xpath = new DOMXPath($dom); $hrefs = $xpath->evaluate("/html/body//a"); for ($i = 0; $i < $hrefs->length; $i++) { $href = $hrefs->item($i); var_dump($href); $url = $href->getAttribute('href'); echo "<...

Sorting xml with simpleXML/xpath?

Hey, I have some xml, say: <Background> <Uses>14</Uses> </Background> <Background> <Uses>19</Uses> </Background> <Background> <Uses>3</Uses> </Background> How can I sort the xml from lowest Uses to highest? Maybe an xpath expression? Also, how could I just retrieve the bottom 2 Backgrounds, or the ones most recently added? Than...

getting xpath 2.0 functions to work in any browser at all

I want to use XPath 2.0 functions, like these: http://www.w3schools.com/xpath/xpath_functions.asp In a browser XSL transform. I can specify the XSL version as 2.0 in the stylesheet tag, but this doesn't seem to activate the 2.0 XPath functions (at least in Firefox). So for example this: <xsl:value-of select="node-name(//testnode)"...

XSL & XPath - Select Element Name of Attribute

Hi! I have a rather specific question perhaps.. I have a user that will enter in some criteria on a form, and then it builds an XPath from their input. Let's say their input creates the following: //*[@color='red']/@* Which essentially means they want to see all attributes of any element with the @color = red. I can display exactl...

Check the existence on an Attribute and non-emptiness of its value

<ROWS> <ROW oid="28439"> <EFL eid="8" fid="27672" count="2" Name = "A : bbb"> <MK id="3" val="0"/> <MK id="11" val="0578678"/> </EFL> </ROW> </ROWS> I have the above xml, i want to have the following loop in XSL if Name attribute in EFL tag Exists And Not Empty Then       Display the v...

Powershell XML parse not working on subnodes

I am tring to parse the following file: <?xml version="1.0" encoding="UTF-8" ?> <printDrivers> <printDriver id="XE8550"> <inf>x28550p.inf</inf> <driverPath>\drivers\XEROX\8550\8550_Driver</driverPath> <printerPaths> <printerPath>\\print-man\man-25</printerPath> </printerPaths> </printDriver> ...

Selecting elements whose attribute begins with something in XPath

As the title says, is it possible to select elements in XPath that only begin with a certain string, but perhaps do not end with the same? For example there are 3 anchor elements: <a href="buy.php/onething"></a><a href="buy.php/twothing"></a><a href="sell.php/anotherthing"></a> I only want to get anchor elements that begin with 'buy....