xpath

Sorting XPath expressions into document order

I need to evaluate multiple XPath expressions against a document. The documents are large, so we're using a streaming parser. The XPath expressions simply return the value of a node. I need to order the XPath expressions so that they are in document order (since once I evaluate an expression, evaluation of the next expression begins a...

Display different xsl:attribute depending on the ending of a string

Dear All, I have the following xsl code in an xsl document <A target="_blank" style="text-decoration=none"> <xsl:attribute name="href">viewdoc.aspx?doc=<xsl:value-of select="URLFilePath"/>&amp;mode=inline</xsl:attribute> <xsl:attribute name="prefix"><xsl:value-of select="File...

Easy XPath question for iPhone

Hey guys! This is driving me NUTS! Here's my XML document <?xml version="1.0" encoding="UTF-8"?> <container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container"> <rootfiles> <rootfile full-path="content.opf" media-type="application/oebps-package+xml"/> </rootfiles> </container> All I want to do is get t...

get value of input field with xpath

I'm trying to get the value of a hidden form with xpath, there are several input fields $dom = new DOMDocument(); @$dom->loadHTML($html); // grab all the page $x = new DOMXPath($dom); $nodes = $x->query('/html/body/div/div[4]/div[2]/input'); foreach ($nodes as $node) { ech...

How to use regular expression in lxml xpath?

I'm using construction like this: doc = parse(url).getroot() links = doc.xpath("//a[text()='some text']") But I need to select all links which have text beginning with "some text", so I'm wondering is there any way to use regexp here? Didn't find anything in lxml documentation ...

Selection attribute value with xpath by filtering on a subitem-value

Hi everyone, how can I select a node-attribute with xpath by filtering on a subnode-attribute? I have a xml structure like this: <base> <item name="foo"> <subitem value="blubb" /> </item> </base> Now I want the name-attribute-value ("foo") from the item-tag(s) where the value-attribute of the subitem(s) is "blubb". Thx 4 he...

How do you query namespaces with PHP/XPath/DOM

I am trying to query an XML document that uses namespaces. I have had success with xpath without namespaces, but no results with namespaces. This is a basic example of what I was trying. I have condensed it slightly, so there may be small issues in my sample that may detract from my actual problem. Sample XML: <?xml version="1.0"?> ...

Absolute Xpath to get list of childnodes?

Hi this my xml file, <?xml version="1.0"?> <worldpatentdata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <meta name="elapsed-time" value="329" xmlns="http://ops.epo.org"/&gt; <exchange-documents xmlns="http://www.epo.org/exchange"&gt; <exchange-document country="AT"...

xmlpoke in Nant - how to update all instances of found string

Hi I am using Xpath in my Nant build script to change some config variables between development and my other environments. I have taken the syntax from this example: The example looks like this: <xmlpoke file="config01/app.config" xpath="/configuration/appSettings/add[@key='AppName']/@value" value="TradeMonster"> </xmlpoke...

XdmException on XQSharp XPathEvaluate

I am trying to evaluate a XPathExpression with XQSharp and get the Error:"Type check error. The empty sequence cannot be cast to type 'xs:integer'." AltovaXMLSpy evaluates it correct as "true". oXmlDoc.CreateNavigator().XPathEvaluate("root/foo/bar cast as xs:integer lt count(root/blah/blub)", oNamespaseManager).ToString() This XML lo...

Selecting only the first item of an xpath result set in PHP

I am currently achieving the desired outcome with two PHP statements: $thisBlarg = $xmlResource->xpath('//blarg[@ID='.$someBlargID.']'); echo $thisBlarg[0]->name; But, not wanting to settle for second best, I'd really prefer this to be one statement, but PHP doesn't like this: echo $xmlResource->xpath('//blarg[@ID='.$someBlargID.']')...

get xml attribute named xlink:href using xsl

How can I get the value of an attribute called xlink:href of an xml node in xsl template? I have this xml node: <DCPType> <HTTP> <Get> <OnlineResource test="hello" xlink:href="http://localhost/wms/default.aspx" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" /> </Get> </HTTP> </DCPType> When I try the f...

XSLT 1.0 : Iterate over characters in a string

I need to iterate over the characters in a string to build an XML structure. Currently, I am doing this : <xsl:template name="verticalize"> <xsl:param name="text">Some text</xsl:param> <xsl:for-each select="tokenize(replace(replace($text,'(.)','$1\\n'),'\\n$',''),'\\n')"> <xsl:element name="para"> <xsl:value...

How do i select the preceding nodes of a text node starting from a specific node and not the root node?

How do i select the preceding nodes of a text node starting from a specific node whose id i know instead of getting the text nodes from the root node? When i invoke the below piece from a template match of text node, I get all the preceding text nodes from the root. I want to modify the above piece of code to select only the text node...

XPATH Query: How to get two elements?

Hello My HTML code is: <table> <tr> <td class="data1"><p>1</td></td> <td class="data1"><p>2</td></td> <td class="data1"><p>3</td></td> <td class="data1"><p>4</td></td> </tr> <tr> <td class="data1"><p>5</td></td> <td class="data1"><p>6</td></td> <td class="data1"><p>7</td></td> <td class="data1"><p>8</td></td> </tr> </table> My query ...

Exclude nodes based on attribute wildcard in XSL node selection

Using cruisecontrol for continuous integration, I have some annoyances with Weblogic Ant tasks and how they think that server debug information are warnings rather than debug, so are shown in my build report emails. The XML output from cruise is similar to: <cruisecontrol> <build> <target name="compile-xxx"> <task name="xxx"...

Xpath and innerHTML

What Xpath expression can I use to find all the anchor (just 'a') elements whose actual text (the innerHTML) is Logout. something like //a[@innerHTML='Logout'] Would that be correct? ...

Is it possible to alter a php file using XPath?

I"m unsure about this. Would having PHP ( or I guess any template language like Django's or Mako or whatever ) inside an html file prevent me from making changes to it with XPath? I'm very new to XPath. I would think that you could not, but as I said, I'm unsure. ...

How to scrape the first paragraph from a wikipedia page?

Let's say I want to grab the first paragraph in this wikipedia page. How do I get the principal text between the title and contents box using XPath or DOM & PHP or something similar? Is there any php library for that? I don't want to use the api because it's a bit complex. Note: i just need that to add a widget under my pages that disp...

How can I get a Node adjacent to a unique Node using Scala?

I'm trying to parse an Apple plist file and I need to get an array Node within it. Unfortunately its only unique identifier is sibling Node right before it, <key>ProvisionedDevices</key>. Right now my best thoughts are to use Java's XPATH querying or Node.indexOf. Here is an example: <plist version="1.0"> <dict> <...