xpath

When do you use XPath over XmlDocument or XmlTextReader?

When do you use XPath over XmlDocument? I'm trying to see things from a higher level. Is there a situation where it is better to use XPath over XmlDocument? ...

XPath Selection Based on Expiration Date Attributes

Given this XML: <?xml version="1.0" encoding="utf-8"?> <content dataType="XML"> <item type="Promotion" name="Sample Promotion" expires="04/01/2009"> <![CDATA[ <p>Details here.</p> ]]> </item> <item type="Promotion" name="Sample Promotion 2" expires="05/01/2009"> <![CDATA[ <p>Details here.</p> ]]> </it...

Accessing Comments in XML using XPath

Hi, How to access the comments inside the XML document using XPath? For example: <table> <length> 12 </length> <!--Some comment here--> </table> I want to access the "Some comment here". Thanks... EDIT: I am using MSXML DOM ActiveX and the command comment() seems to be failing... Any idea why? ...

BizTalk xpath with a default namespace and no prefixes

I'm struggling with the BizTalk xpath functionality - the message I'm getting has a blank default namespace - in C# I'd add a NameSpaceManager - but I can't see how I can do this in a BizTalk Expression ? All I'm failing to do is get the values of the HasErrors and NumberOfErrors <?xml version="1.0" encoding="utf-8"?> <ImportInd...

xslt test if a variable value is contained in a node set

I have the following two files: <?xml version="1.0" encoding="utf-8" ?> <!-- D E F A U L T H O S P I T A L P O L I C Y --> <xas DefaultPolicy="open" DefaultSubjectsFile="subjects.xss"> <rule id="R1" access="deny" object="record" subject="roles/*[name()!='Staff']"/> <rule id="R2" access="deny" object="diagnosis" subject="roles//Nurse"...

How to use XPath/Xsl to compare child element with the same child element under a different parent ?

I need to use xsl/xpath (version 1.0) to do something special (for simplifying, say insert some dummy text) when the value of SupplierId changes. I need to handle 3 variations; Do something when on the first Order (the first occurence of SupplierId) Do somwthing when on OrderId O3 (SupplierId changed from S1 to S2) Do something when o...

Tool / utility for checking debugging XPath queries

Has anyone got any recommendations for tools/utilities to use in creating/debugging XPath queries for Windows ? ...

Produce context data for first and last occurrences of every value of an element

Given the following xml: <container> <val>2</val> <id>1</id> </container> <container> <val>2</val> <id>2</id> </container> <container> <val>2</val> <id>3</id> </container> <container> <val>4</val> <id>1</id> </container> <container> <val>4</val> <id>2</id> </container> <container> <val>4</val>...

How to filter with XPath on all elements without a specific attribute

My XPath is a little bit rusty... Let's say I have this simple XML file: <?xml version="1.0" encoding="utf-8" ?> <States xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <States> <StateProvince name="ALABAMA" abbrev="AL" /> .... <StateProvince name="AMERICAN SAMOA" abbrev="AS" territ...

php xpath - string functions on a attribute

What is the correct syntax for applying string functions (e.g. "normalize-space") on a attribute using the xpath query below? Query: "./@media" I've seen examples of this elsewhere but if I try it using php's xpath library it returns nothing... ...

Xpath visualization

I am looking for a XML tool which does the following things. Allows me to enter xpath expressions and highlights the nodes selected Assists me in creating complex xpath expressions. What are other people using out there? I've used something from source forge but it only selects one matched node. ...

XPaths and <? ?>

I have a WIX file that I need to modify using MSBuild. It starts like this: <?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension"&gt; <?--... Removed Params ...--> <?define ProductVersion = "1.0.1"?> <?--... Removed Params ......

XPath in MSBuild (SDC) and WIX

Fresh Asking of this Question-> I have a WIX file that I need to modify using MSBuild. It starts like this: <?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension"&gt; <?--... Various Removed Params ...--> <Product Id='$(var.Produ...

PHP XPath explicit node...

I am trying to pull an exact table during a "web scrape." Used cURL to pull page into $html, which succeeds fine. Used Firebug to get exact XPATH to the table needed. Code follows: $dom = new DOMDocument($html); $dom->loadHTML($html); $xpath = new DOMXpath($dom); $summary = $xpath->evaluate('/html/body/table[5]/tbody/tr/td[3]/table/t...

How do I get Nokogiri to understand my namespaces?

I have the following XML document: <samlp:LogoutRequest ID="123456789" Version="2.0" IssueInstant="200904051217"> <saml:NameID>@NOT_USED@</saml:NameID> <samlp:SessionIndex>abcdefg</samlp:SessionIndex> </samlp:LogoutRequest> I'd like to get the content of the SessionIndex (that is, 'abcdefg') out of it. I've tried this: XPATH_QUE...

How can I use XPath to get elements?

My XML is like: <root> <section name="blah"> <item name="asdf">2222</item> </section> </root> I will have multiple 'sections' in the XML, I want to fetch a particular section. In this case, I need to get items that are in the section named "blah". ...

Error when trying to load XML from a Sharepoint Web Services call into an ASP.NET Gridview

I'm getting the error: Illegal characters in path. when trying to load XML, using XPath, into a gridview's datasource in the PageLoad function in the code-behind of an ASP.NET page I'm building. Does anyone know what this error means? The XML coming in from the Sharepoint Web Services call is: <?xml version='1.0' encoding='ISO...

Why is XPathSelectElement is giving a NullReferenceException?

The following code gives a NullReferenceException since XPathSelectElement can't navigate through the XPath expression I've given: String description = (String)node.XPathSelectElement("//car").Attribute("description"); I've debugged this and verified that the node is being read correctly, and that the elements in my XPath are capitali...

Finding Directed Acyclic Graph (DAG) Minimal Elements (Vertices) with XSLT/XPath?

I have an XML file that encodes a directed acyclic graph (DAG) that represents a partial order. Such graphs are useful for things like specifying dependencies and finding critical paths. For the curious, my current application is to specify component dependencies for a build system, so vertices are components and edges specify compile-t...

C#: "Swedish" characters in Xpath when parsing Lating1Encoded docs.

I've a set of html docs that I need to parse. They are encoded in Latin1Encoded. I'm using HtmlAgiliy pack for "parsing". I have a Xpath query (with swedish characters) that I can't get to work because of different encodings between the docs and the encoding VS stores the XPath query in?? Xpath query: doc.DocumentNode.SelectNodes(@"/...