Questions tagged [xpathnavigator]

The XPathNavigator provides a cursor model for navigating and editing XML data.

The System.Xml.XPath.XPathNavigator provides a cursor model for navigating and editing XML data.

120 questions
66
votes
14 answers

Using Xpath With Default Namespace in C#

I've got an XML document with a default namespace. I'm using a XPathNavigator to select a set of nodes using Xpath as follows: XmlElement myXML = ...; XPathNavigator navigator = myXML.CreateNavigator(); XPathNodeIterator result =…
macleojw
  • 4,113
  • 10
  • 43
  • 63
26
votes
1 answer

How to traverse back to the parent node in the XML file by using Xpath(using XSLT) query?

Let us have a xml tree of depth N. I have traveresd the last node means i am at last note. Now i wanted to go back to some level up (say at N-3) in the xml tree from that last node. Please let me know the syntax for the XPATH query so that i can…
Santosh kumar
  • 342
  • 1
  • 3
  • 6
11
votes
3 answers

Get attribute values from matching XML nodes using XPath query

This doesn't seem like it should be difficult, but I'm stuck currently. I'm trying to get the attribute values for a particular attribute from nodes that match a given XPath query string. Here's what I have so far: public static…
Sarah Vessels
  • 30,930
  • 33
  • 155
  • 222
7
votes
2 answers

Easy XPathNavigator GetAttribute

Just getting started here with my first take at XPathNavigator. This is my simple xml:
bgmCoder
  • 6,205
  • 8
  • 58
  • 105
6
votes
2 answers

Which is the best for performance wise: XPathNavigator with XPath vs Linq to Xml with query?

I have an application in which I am using XPathNavigator to iterate nodes. It is working fine. But I want to know that if I use LINQ to Xml.... What benefits(Performance, maintainability) I will get? With XPath, LINQ to Xml what is the performance…
Syed
  • 931
  • 13
  • 28
6
votes
2 answers

Parse XPath Expressions

I am trying to create a 'AET' (Abstract Expression Tree) for XPath (as I am writing a WYSIWYG XSL editor). I have been hitting my head against the wall with the XPath BNF for the past three to four hours. I have thought of another solution. I…
Jonathan C Dickinson
  • 7,181
  • 4
  • 35
  • 46
6
votes
2 answers

How do I find a XML element using c# when I know the exact path?

How do I get information from an xml document? I have an xml document at c:\temp\data.xml and am using visual studio. The closest I can figure is: XmlDocument xdoc = new XmlDocument(); xdoc.Load(@"C:\temp\data.xml"); date =…
Richard Walton
  • 61
  • 1
  • 1
  • 2
5
votes
1 answer

How to select a node using XPathNavigator.SelectSingleNode(string xpath)?

I have this xml file "target.xml":
Răzvan Flavius Panda
  • 21,730
  • 17
  • 111
  • 169
5
votes
2 answers

Can't Get .NET XPathNavigator to work

I am having problems with XPathNavigator. I have a document with a bunch of "topic" elements w/o namespace in a stream. I am using (expression dumbed down to bare minimum, first I thought my expressions were wrong): XPathDocument xmlDoc = new…
Sergey
  • 636
  • 6
  • 12
4
votes
1 answer

How to retrieve values using XPathNodeIterator

I am trying to select values from elements using the XPathNodeIterator. But I am not able to get the expected value from my XML file. My XML file
hwcverwe
  • 5,287
  • 7
  • 35
  • 63
4
votes
1 answer

What's wrong with UNORDERED_NODE_ITERATOR_TYPE with a specific xml document?

I'm having a trouble by retrieving the elements of an xml document. I got it through a request, parsed, and then I did the following: var results = xDoc.evaluate( "pets/pet[@name='Foo']", xDoc, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE,…
gal007
  • 6,911
  • 8
  • 47
  • 70
4
votes
2 answers

string-join and tokenize xpath functions in C#

For an ASP.NET project I wrote a controller action and a form where the user can enter an xpath expression and retrieve the result from an xml file on the server. It works fine, even with some string functions like concat, substring-before and…
Explicat
  • 1,075
  • 5
  • 16
  • 40
4
votes
1 answer

Why do I have to pass an empty namespace to XPathNavigator.GetAttribute?

Given the following XML markup: and an XPathNavigator positioned on the element, string withNs = navigator.GetAttribute("name", navigator.NamespaceURI); string withoutNs =…
Jens Bannmann
  • 4,845
  • 5
  • 49
  • 76
3
votes
1 answer

How do I use XPATH to parse the following that has a namespace?

I need to extract a claim from a SAML token. The claim I'm interested in is http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider and I'd like to get the value "Google" in this case. What am I doing wrong in the…
TLDR
  • 1,198
  • 1
  • 12
  • 31
3
votes
0 answers

XPathNavigator and UnderlyingObject returns different objects with the same xpath

I'm a bit confused on UnderlyingObject property in XPathNavigator. There are 2 issues: 1) in .net version 3.5 and below, UnderlyingObject returns null value by giving the valid xpath in select. 2) in .net version 4 and above, UnderlyingObject…
TimMe
  • 131
  • 1
  • 4
1
2 3 4 5 6 7 8