Read XML Data from C#
-
hi i need to read XML data from an XML file into C#.i tried using XmlTextReader class but i am not getting all elements. My XML file is as follows
<?xml version="1.0"?>
<Form1>
<button>username</button>
</Form1>My code is as follows
// Create an instance of XmlTextReader and call Read method to read the file
XmlTextReader textReader = new XmlTextReader("C:\\\\books.xml"); textReader.Read(); // If the node has value while (textReader.Read()) { // Move to fist element textReader.MoveToElement(); Console.WriteLine("Attribute Count:" + textReader.Value.ToString()); }
in the above code i am not getting all the nodes and elements...(maybe due to whitespaces) please give links to any code samples etc...is there any other method to read?? thanks in advance...
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
-
hi i need to read XML data from an XML file into C#.i tried using XmlTextReader class but i am not getting all elements. My XML file is as follows
<?xml version="1.0"?>
<Form1>
<button>username</button>
</Form1>My code is as follows
// Create an instance of XmlTextReader and call Read method to read the file
XmlTextReader textReader = new XmlTextReader("C:\\\\books.xml"); textReader.Read(); // If the node has value while (textReader.Read()) { // Move to fist element textReader.MoveToElement(); Console.WriteLine("Attribute Count:" + textReader.Value.ToString()); }
in the above code i am not getting all the nodes and elements...(maybe due to whitespaces) please give links to any code samples etc...is there any other method to read?? thanks in advance...
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"