1
Reply

How to read Content of Element Node

Amrit

Amrit

Nov 8 2006 1:31 AM
2k

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
<c>
<a>hi</a>
<b>hello</b>
</c>


Answers (1)