xpath

How to use XPATH in MySQL select?

Say I have a table called "xml" that stores XML files in a single column "data". How would I write a MySQL query that run an XPath and return only rows matching that XPath? ...

ASP.NET: Casting XPath to bool - Possible?

Greetings! I have an XML value that I'd like to use as a boolean value to toggle the visibility of a Panel. I have something like this: <asp:FormView id="MyFormView" runat="server" DataSourceID="MyXmlDataSource"> <ItemTemplate> <!-- some stuff --> <asp:Panel id="MyPanel" runat="server" Visible='<%# (bool)XPath("Men...

PHP simplexml: why does xpath stop working?

A strange thing happened after a supplier changed the XML header a bit. I used to be able to read stuff using xpath, but now I can't even get a reply with $xml->xpath('/'); They changed it from this... <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE NewsML SYSTEM "http://www.newsml.org/dl.php?fn=NewsML/1.2/specification/NewsML_...

With XSLT/XPath, how can I match any element in the null namespace?

<xsl:template match="foo"> matches the foo element in the null namespace. <xsl:template match="*"> matches any element in any namespace. I tried: xmlns:null="" ... <xsl:template match="null:*"> but it's illegal to declare a prefix for the null namespace. So how can I match an element with any name in the null namespace? ...

Finding a node (or close to it) using XPath in non well-formed HTML

I'm using XPath to locate a node (or something close to it) in a template that has non-well-formed HTML about 10 levels deep. (No I didn't write this HTML...but I've been tasked to dig through it.) I seem to be able to retrieve an XPath to the element in question using the XPartner add-on for Firefox; however it only gives me the loc...

Xpath query to select node when attribute does not exist?

I want to select nodes for which a specific attribute does not exist. I've tried the Not() function, but it doesn't work. Is there a way for this? Example: The following Xpath query: group/msg[not(@owner)] Should retrieve the first node but not the 2nd one. However, both SketchPath (tool to test Xpath queries) and my C# code consider...

Xpath sibling conditional testing?

I'm using VB.net (2003), and calling the SelectNodes method on an xml document. If I have a document: <InqRs> <DetRs> <RefInfo> <RefType>StopNum</RefType> <RefId>0</RefId> </RefInfo> <RefInfo> <RefType>Id</RefType> <RefId>0</RefId> </RefInfo> </DetRs> <DetRs> <RefInfo> <RefType>Sto...

Finding an XmlNode by attribute in ASP.net

Hi, I'm trying to write some code to find a specific XmlNode object based on the URL in the XML sitemap but can't get it to find anything. The sitemap is the standard ASP.net sitemap and contains: <siteMapNode url="~/lev/index.aspx" title="Live-Eye-Views"> --- Child Items --- </siteMapNode> The code I'm using to search for the eleme...

How to get tag name of root element in an XML document w/ XSLT?

Hi all, I'm interested in assigning the tag name of the root element in an xml document to an xslt variable. For instance, if the document looked like (minus the DTD): <foo xmlns="http://....."&gt; <bar>1</bar> </foo> and I wanted to assign the string 'foo' to an xslt variable. Is there a way to reference that? Thanks, Matt ...

Looking for XML parser

I have been tasked with finding an open source DOM XML parser. The parser must minimally support XPath 1.0. Schema support is desired, but not a deal breaker The files we are parsing will be small so speed and memory consumption are not a large concern. Any OO language (C++, C#, Java, etc.). To clarify, the plan is to integrate ...

Traversing an arbitrary C# object graph using XPath/applying XSL transforms

I've been looking for a component that would allow me to pass an arbitrary C# object to an XSL transform. The naive way of doing this is to serialise the object graph using an XmlSerializer; however, if you have a large object graph, this could cause problems as far as performance is concerned. Issues such as circular references, lazy l...

What is a good way to find a specific value in an XML document using C#?

I'm calling a WebService exposed by Oracle that accepts an input of an ItemID and returns to me the corresponding Item Number. I want to grab the Item Number that has been returned out of the XML contained in the response. The XML looks like this: <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http:/...

How to save XPathExpression result to separate XML with ancestor structure?

Hi! I'm parsing big XML file with XPathExpression selection for some nodes existing at various depth levels. What is the easiest way to export selected nodes to separate XML file, preserving all direct-ancestors nodes (and their attributes)? C# is preferred. Example source XML : <a> <x> <b> <c/> <z/> </b> <c/> </a> <c/...

Implementing my own XPathNavigator in C#

I am looking for a C# example implementation of a class derived from Microsoft's XPathNavigator class. Can any one point me at such an article? As you may (or may not) know, the XmlNavigator is designed to allow one to superimpose XPath navigation on most any data model. I have implemented my derived XPathNavigator class and it work...

Locating the node by value containing whitespaces using XPath

Hi there, I need to locate the node within an xml file by its value using XPath. The problem araises when the node to find contains value with whitespaces inside. F.e.: value value with spaces I can not construct the XPath locating the second Child node. Simple XPath /Root/Child perfectly works for both children, but /Root[Chil...

XSLT distinct elements and grouping

Given the following xml fragment: <Problems> <Problem> <File>file1</File> <Description>desc1</Description> </Problem> <Problem> <File>file1</File> <Description>desc2</Description> </Problem> <Problem> <File>file2</File> <Description>desc1</Description> </Problem> </Problems> I need to produce someth...

How to capture only part of an id?

I'm trying to capture the id of an element that will be randomly generated. I can successfully capture the value of my element id like this... | storeAttribute | //div[1]@id | variableName | Now my variable will be something like... divElement-12345 I want to remove 'divElement-' so that the variable I am left with is '12345' so th...

How to use XPath function in a XPathExpression instance programatically?

My current program need to use programatically create a XPathExpression instance to apply to XmlDocument. The xpath needs to use some XPath functions like "ends-with". However, I cannot find a way to use "ends-with" in XPath. I It throw exception like below Unhandled Exception: System.Xml.XPath.XPathException: Namespace Manager ...

Can I use a Regex in an XPath expression?

Something like ".//div[@id='foo\d+]" to capture div tags with id='foo123'. I'm using .NET, if that matters. ...

How best to use XPath with very large XML files in .NET?

I need to do some processing on fairly large XML files ( large here being potentially upwards of a gigabyte ) in C# including performing some complex xpath queries. The problem I have is that the standard way I would normally do this through the System.XML libraries likes to load the whole file into memory before it does anything with it...