xpath

In XPATH, use data from the current context to filter other data

Is there a way to use data from the current context to filter nodes somewhere else in the statsource. For instance, if I have this XML: <root> <group1> <inst> <type>Foo</type> <value>First Foo</value> </inst> <inst> <type>Bar</type> <value>The Bar</value> ...

How do I build XQuerys to include/exclude rows based on the presence of certain tags and attributes?

I have an auditing/logging system that uses raw XML to represent actions taken out by an application. I'd like to improve on this system greatly by using an XML column in a table in the application's SQL Server database. Each row in the table would contain one log entry and each entry should contain one or more tags that are used to de...

Problem with namespace and libxml when i use Xpath

hi i've got a problem when i'm using libxml with XPath. I want to parse an youtube playlist : <?xml version='1.0' encoding='UTF-8'?> <feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xm...

What XSLT 2.0 tools exist?

Hello all, I'm trying to wrap my head around XML and XSLT stuff, and in my research I stumbled upon different XSLT processors. Xalan was the first one, and it seems to work pretty fine and is free, except that I need/want to use features in the 2.0 specs, including XML Schema. To do so I must either work with extensions and Xalan, or sw...

XPath: Recursive Ancestor Search

With my current node selected I wish to find an element <name> [./name] and return the text content. If an element <name> does not exist in the currently selected node I wish to check the parent element [./parent::name] and so on recursively up to the root, returning the value of the nearest parent where the element exists. Can it be do...

How to write XPath to capture text that is not tagged

I'm trying to scrap customer reviews from a site and ran into an interesting set-up. <div class="Review"> <img class="stars" etc> <b>ReviewerName</b> - yyyy-mm-dd <br/> <p>Review</p> <a>was this helpful links</a> <hr/> <br/> <!-- Repeat above for additional reviews. --> </div> For the life of me I can't come up with ...

How to retrieve all links from HTML document using DOMXPath

Hello I have this code <?PHP $content = '<html> <head> <title></title> </head> <body> <ul> <li style="border:0px" class="list" id="list1111"> <a href="http://www.example.com/" style="font-size:10px" class="mylinks"> <img src="logo.gif" width="235" height="...

Sorting an the content of an XPathNodeIterator in C#

I have a DLL which I (for many reasons) cannot change. I use this assembly to retrieve a an XPathNodeIterator. I know I can sort XML with an XPathExpression on an XPathNavigator to get an XPathNodeIterator, the problem is that I start from the XPathNodeIterator is there any way to apply a sort afterward? ...

xpath to xsd definition

I am looking for a way to take a xpath for an instance xml file and use it to find the xsd element. If possible are there any xsl or .net examples? ...

nokogiri xpath expressions not parsing

I am using Nokogiri 1.3.3 with Ruby 1.8.7 I am trying to match the content of a tag as described in this SO question: nodeset.xpath("entry/index[. = '#{index.to_s}']/../categories") Nokogiri raises an exception complaining about the '.' after the bracket. When I replace the '.' with text() it then complains about the second period. ...

How to view object's data in php

Hello when I want to test php array I use the following code print_r($myarray); but know I want to see the data of an object my object is $xpath = new DOMXPath($doc); $myobject = $xpath->query('//*[ancestor-or-self::a]'); when I use print_r($myobject); I get that output DOMNodeList Object ( ) I want to i...

Parsing XML document with XPath, C#

Hi, So I'm trying to parse the following XML document with C#, using System.XML: <root xmlns:n="http://www.w3.org/TR/html4/"&gt; <n:node> <n:node> data </n:node> </n:node> <n:node> <n:node> data </n:node> </n:node> </root> Every treatise of XPath with namespaces tells me to do the following: XmlNamespaceManager mgr...

how to match the processing-instruction element in xslt ??

I have some processing-instructions elements inside my xml content, for example : <?legalnoticestart?> <?sourcenotestart?> <para>Content para</para> <?sourcenoteend?> <?literallayoutstart?> <para>body content </para> <?literallayoutend?> <?legalnoticeend?> How can i match these elements and get the content in the below required eleme...

PHP Scraping Page

I'm trying to scrape a page where the information I'm looking for lies within: <tr class="defRowEven"> <td align="right">label</td> <td>info</td> </tr> I'm trying to get the label and info out of the page. Before I was doing something like: $hrefs = $xpath->evaluate("/html/body//a"); That is how I'm grabbing the URL's. Is t...

How do I return the result of a function with XPath?

I'm new to using XPath so I've been fooling around with an XPath Evaluator and I'm trying to find out how to return the value of a function. If I want to return the hrefs of all the links on a page I can use the following XPath: //a/@href If I want to return all the links with hrefs longer than 20 chars I can use this: //a[string-le...

Can I use XPath functions with XPathNavigator?

I've got an XPathNavigator at the root of a document. Several levels down, there's a group of numeric values that I want to sum. I could always loop through the nodes and add them myself, but since I knew the XPath spec included a sum function, I decided to try to use that. I'm running into an error. System.Xml.XPath.XPathException - Ex...

XSLT functions and namespaces

I'm kind of new to XSLT, and I've gotten basic transformation done. Next I want to try out date manipulations, since my data will have timestamps. However, I can't seem to get any date functions to work, and it greatly frustrates me. I'm testing using Firefox 3.5, xsltproc 1.1.24, xalan 1.10, and XMLSpy 2009, and they all say that the fu...

How to handle escaped characters in XPath expressions for Nokogiri

I'm using nokogiri with an xml document that looks something like this: <songs> <song> <artist>Juana Molina</artist> <album>Un Dia</album> <track>8</track> <title>Dar (Qu&#233; Dif&#237;cil)</title> <rating>5</rating> <filename>\Juana Molina\Un Dia\08 - Juana Molina - Dar (Qu&#233; Dif&#237;cil).mp3</filename> ...

XPath: How to match attributes that contain a certain string

I have the problem to get the node if there is more than one attribute. Example: <div class="atag btag" /> This is my xpath expression: //*[@class='atag'] The expression only works with <div class="atag" /> but not for the above shown. Any suggestions? ...

XML path - case insensitive

How to convert XML xpath as case insensitive? XmlNodeList elements = mConfig.SelectNodes(path); path can be - Config/Setting/Name or config/setting/name ...