Problem with SelectNodes

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am having a problem select nodes with the XmlDocument SelectNodes method I am kinda lost now.
Can somebody see what I am doing wrong? No matter what I do, I get 0 nodes back.


<div style="color:Black;background-color:White; <pre>

XmlNodeList nodes = docOutXML.SelectNodes(<span style="color:#A31515; "/Packet/Result/dValue");
<span style="color:Green; // I tried everything, no nodes, never, nada....
<span style="color:Green; //SelectNodes("/Result/dValue"); SelectNodes("Packet");

<span style="color:Blue; foreach (XmlNode node <span style="color:Blue; in nodes) <span style="color:Green; //nodes.Count == 0... always
{
<span style="color:Green; // I want to remove the nodes called dValue,
<span style="color:Green; // but I never get there
node.ParentNode.RemoveChild(node);
}

<span style="color:Green; // then I tried this to see if there are nodes in the doc:
XmlNode rootnode = docOutXML.DocumentElement <span style="color:Blue; as XmlNode;
BasicFileLogger.WriteLine(rootnode.Name);
<span style="color:Blue; foreach (XmlNode n <span style="color:Blue; in rootnode.ChildNodes)
{
BasicFileLogger.WriteLine(rootnode.Name +<span style="color:#A31515; ", " + n.Name);
<span style="color:Blue; foreach (XmlNode nc <span style="color:Blue; in n.ChildNodes)
{
<span style="color:Green; // Nevertheless I do get here, hence there are nodes called
<span style="color:Green; //dValue in this document
BasicFileLogger.WriteLine(rootnode.Name + <span style="color:#A31515; ", " + n.Name + <span style="color:#A31515; ", " + nc.Name);
}
}

<span style="color:Green; //This is the logging output of the above
<span style="color:Green; //Packet
<span style="color:Green; // ...
<span style="color:Green; //Packet, Result
<span style="color:Green; //...
<span style="color:Green; //Packet, Result, dVolume

[/code]
<br/>
<br/>


View the full article
 
Back
Top