T
Tony Johansson
Hello!
Below is some code and the xml file that I use.
If I examine the reader variable before row marked with 1 is executed we
have the following contents in the reader variable {Element,Name="book"}
What I don't fully understand is why ReadElementString() write out at 1 "The
Handmaid's Tale"
when the reader contains book. I would understand it if reader had been
title.
Can somebode explain that ?
//main
{
//Load the file and ignore all whitespace.
XmlTextReader reader = new XmlTextReader("test.xml");
reader.WhitespaceHandling = WhitespaceHandling.None;
//Moves the reader to the root element.
reader.MoveToContent();
//Read the title and price elements.
1 Console.WriteLine("Content of the title element: {0}",
reader.ReadElementString());
Console.WriteLine("Content of the price element: {0}",
reader.ReadElementString());
}
<?xml version="1.0" encoding="utf-8" ?>
<book>
<title>The Handmaid's Tale</title>
<price>14.95</price>
</book>
//Tony
Below is some code and the xml file that I use.
If I examine the reader variable before row marked with 1 is executed we
have the following contents in the reader variable {Element,Name="book"}
What I don't fully understand is why ReadElementString() write out at 1 "The
Handmaid's Tale"
when the reader contains book. I would understand it if reader had been
title.
Can somebode explain that ?
//main
{
//Load the file and ignore all whitespace.
XmlTextReader reader = new XmlTextReader("test.xml");
reader.WhitespaceHandling = WhitespaceHandling.None;
//Moves the reader to the root element.
reader.MoveToContent();
//Read the title and price elements.
1 Console.WriteLine("Content of the title element: {0}",
reader.ReadElementString());
Console.WriteLine("Content of the price element: {0}",
reader.ReadElementString());
}
<?xml version="1.0" encoding="utf-8" ?>
<book>
<title>The Handmaid's Tale</title>
<price>14.95</price>
</book>
//Tony