how do i read the specific tag ?
-
hi all This is to read the tag line by line. using System.Xml; ... ... ... XmlTextReader reader = new XmlTextReader ("reader.xml"); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. Console.Write("<" + reader.Name); Console.WriteLine(">"); break; case XmlNodeType.Text: //Display the text in each element. Console.WriteLine (reader.Value); break; case XmlNodeType.EndElement: //Display the end of the element. Console.Write("</" + reader.Name); Console.WriteLine(">"); break; } } Console.ReadLine(); How do i read the specific tag if i just want to read all the tag that have this < big > tag? thank you
-
hi all This is to read the tag line by line. using System.Xml; ... ... ... XmlTextReader reader = new XmlTextReader ("reader.xml"); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. Console.Write("<" + reader.Name); Console.WriteLine(">"); break; case XmlNodeType.Text: //Display the text in each element. Console.WriteLine (reader.Value); break; case XmlNodeType.EndElement: //Display the end of the element. Console.Write("</" + reader.Name); Console.WriteLine(">"); break; } } Console.ReadLine(); How do i read the specific tag if i just want to read all the tag that have this < big > tag? thank you
This might help you get started:
reader.ReadToFollowing("big");
do
{
// Process data ...
} while (reader.ReadToNextSibling("big"));"We make a living by what we get, we make a life by what we give." --Winston Churchill
-
hi all This is to read the tag line by line. using System.Xml; ... ... ... XmlTextReader reader = new XmlTextReader ("reader.xml"); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. Console.Write("<" + reader.Name); Console.WriteLine(">"); break; case XmlNodeType.Text: //Display the text in each element. Console.WriteLine (reader.Value); break; case XmlNodeType.EndElement: //Display the end of the element. Console.Write("</" + reader.Name); Console.WriteLine(">"); break; } } Console.ReadLine(); How do i read the specific tag if i just want to read all the tag that have this < big > tag? thank you
You can use XPath to simplify your work. For example: XmlDataDocument xmlDoc = new XmlDataDocument(); xmlDoc.Load("yourfile.xml"); XmlNodeList xmlNodeList = xmlDoc.SelectNodes("roottag/big"); //XPath expression More detail information pls. refer to Microsoft MSDN.
Welcome to www.softwaretree.net! You can find many excellent audio/video converter tools there!
-
You can use XPath to simplify your work. For example: XmlDataDocument xmlDoc = new XmlDataDocument(); xmlDoc.Load("yourfile.xml"); XmlNodeList xmlNodeList = xmlDoc.SelectNodes("roottag/big"); //XPath expression More detail information pls. refer to Microsoft MSDN.
Welcome to www.softwaretree.net! You can find many excellent audio/video converter tools there!
Unfortunately, our poster is using
XmlTextReader
. You don't use XPath with that."We make a living by what we get, we make a life by what we give." --Winston Churchill