Skip to content

How to read Content of Element Node

Amrit

Asked Nov 7, 2006, 8:31 PM EST1 answer
Share
LinkedInX

Greeting to all,

I am building XMl parser in c#.net, What i have accomplished till now is that you upload any xml it will return the distinct xml element tags, as the columns of a table.

Now the problem is occuring when i am trying to read the Content(value) of an Element Node.

Code is somewhat like this:

XmlTextReader xmlreader = new XmlTextReader ();
if(xmlreader.NodeType == XmlNodeType.Element)
{
  string name = xmlreader.Name.tostring();
  string value = xmlreader.Value.tostring(); // In this case it returns blank value as the node is   textnode. Then i tried using this

  xmlreader.Read(); // This skips the current node and jumps to the next
  string value = xmlreader.Value.tostring(); 
//But again in vain
 
}

Any thoughts ?????


The xml can be like this or any format

hi
hello

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.