xpathnavigator

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...

Parse XPath Expressions

Hi, 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 thought I could write a class that implements IXPathNavigable, which returns a XPathNaviga...

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 = navigator.Select("/outerelement/innerelement"); I am not getting any results back: I'm assuming this ...

Is it possible to retrieve the original XML from XPathNavigator?

I have an XML document, want to do syntax highlighting. The code uses XPathDocument, XPathNavigator and XPathNodeIterator . After I call Select(), how can I get the original text in the XML document? var xpathDoc = new XPathDocument(new StringReader(this.richTextBox1.Text)); var nav = xpathDoc.CreateNavigator(); XmlNamespaceManager...

Can't read xml through XPathNavigator

Here is my code, I don't know why I can't read the data through XPathNavigator. But it was well before I add namespace and schema. XmlReaderSettings settings = new XmlReaderSettings(); settings.Schemas.Add("http://www.somewhere.com", schemaPath); settings.ValidationType = ValidationType.Schema; XmlRe...

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

Given the following XML markup: <root xmlns="Demo"> <child name="foo"/> </root> and an XPathNavigator positioned on the <child> element, string withNs = navigator.GetAttribute("name", navigator.NamespaceURI); string withoutNs = navigator.GetAttribute("name", ""); produce strange results: withNs is empty, withoutNs contains foo....

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 XPathDocument( stream ); XPathNavigator xml = xmlDoc.CreateNavigator(); XPathNodeIterator iter...

XPathNavigator in Silverlight

I have a code library that makes heavy use of XPathNavigator to parse some specific xml document. The xml document is cross-referenced, meaning that an element can reference another which has not yet been encountered during parsing: <ElementA ...> <DependentElementX id="1234"> </ElementA> <ElementX id="1234" .../> The document do...

How to avoid avoid linebreaks and spaces for XmlWellFormedWriter

Hi, i am getting an XmlWriter of the AppendChild() method of a xPathNavigator. using (XmlWriter writer = xPathNavigator.AppendChild()) { writer.WriteStartAttribute("name"); writer.WriteEndElement(); } The AppendChild() method returns a instance of XmlWellFormedWriter. I want to avoid l...

Can I get an XPathNodeIterator directly from an XPath?

I hope I'm just missing something obvious. I have a number of repeating nodes in an XML document: <root> <parent> <child/> <child/> </parent> </root> I need to examine the contents of each of the <child> elements in turn, so I need an XPathNodeIterator containing the nodeset of all the <child> nodes. If I have an XPath th...

Need Help About Using XPathNavigator in C#?

Hello. My XML file as below. It mixed schema and normal elements. <?xml version="1.0" encoding="utf-8"?> <!-- R1 --> <ax:root xmlns:ax="http://amecn/software/realtime/ax"&gt; <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <xsd:element name="EquipmentConstants"> <xsd:complexType> <xsd:sequence> ...

XPath Performance in .NET with Positional Predicates

Given the XML <PSG> <C id="1"> <N id="2" > <A id="3" /> <D id="4"> <PP /> </D> <V id="5" > <Tn /> <P /> </V> <N id="6" > <D id="7" /> <D id="8" /> </N> ...

xPath Evaluate vs XPathNodeIterator

I am searching the fastest way to count some tags in a huge xml-file (120MB) long Quantity; XPathDocument xDocData = new XPathDocument(str_File_path); XPathNavigator xNavData = xDocData.CreateNavigator(); //Option 1 XPathExpression xExp = xNavData.Compile("sum(Tag/Value)"); Quantity = Convert.ToInt64(xNavData.Evaluate(xExp)); //Option...

VB.NET: XPath problem

Hi, I have the follwing XML: <?xml version="1.0" encoding="utf-8" ?> <configuracoes> <gerais> <atualizacoes> <tipo>automática</tipo> <frequencia>diária</frequencia> </atualizacoes> </gerais> </configuracoes> And the code: Dim xPathNavigator As XPathNavigator Dim xPathNodeIterator As XPathNodeIterator xPathNav...

How to travese 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 reached at intended node in the xml tree. ...

Rename an element using XPathNavigator

I have an XPathNavigator object pointing to an XML element. I want to rename the element to another name (and also rename the associated end element). Can this be done using the XPathNavigator? (I have a work-around, which is to Delete the element and re-insert it under a different name, but this may cause a performance issue, because...

Can an XMLDocument object be use with an XPathDocument object?

I have a static method that converts a html file and returns an XMLDocument object. After doing extensive research, the following question has arised: Can pass an XMLDocument object to a XPathDocument object, to make it easy when simply reading data from the document and not editing it. Research01 MSDN Please reply and let me know i...

Adding and manipulating multiple child nodes using XPathNavigator in C#

Hello, I'm writing classes which (de)serialize to/from XML. When serializing and deserializing, the class gets a XPathNavigator to get data from/add data to. Because the class may contain objects which are need to be serialized too (using the same mechanism), I do the following to add a child element for each object: public void Seria...