D
Dan Aldean
Hi,
I create this XML document:
<?xml version="1.0"?>
<Bookstore>
<Book Genre="Novel" Style="hardcover">
<author>
<first-name>Margaret</first-name>
<last-name>Atwood</last-name>
</author>
<Title>The Handmaid's Tale</Title>
<Price>$19.25</Price>
</Book>
<Book Genre="Novel" Style="hardcover">
<author>
<first-name>Barbara</first-name>
<last-name>Kingsolver</last-name>
</author>
<Title>The Poisonwood Bible</Title>
<Price>$11.99</Price>
</Book>
</Bookstore>
Then I try to read and get the values from it using this code:
XmlTextReader xmlTextReader = new XmlTextReader("Sample.xml");
while (xmlTextReader.Read())
{
if (xmlTextReader.NodeType == XmlNodeType.Element)
lstBox.Items.Add(xmlTextReader.Value);
}
It only returns empty values. I would have expected for example:
first-name element to be Margaret
Thanks
I create this XML document:
<?xml version="1.0"?>
<Bookstore>
<Book Genre="Novel" Style="hardcover">
<author>
<first-name>Margaret</first-name>
<last-name>Atwood</last-name>
</author>
<Title>The Handmaid's Tale</Title>
<Price>$19.25</Price>
</Book>
<Book Genre="Novel" Style="hardcover">
<author>
<first-name>Barbara</first-name>
<last-name>Kingsolver</last-name>
</author>
<Title>The Poisonwood Bible</Title>
<Price>$11.99</Price>
</Book>
</Bookstore>
Then I try to read and get the values from it using this code:
XmlTextReader xmlTextReader = new XmlTextReader("Sample.xml");
while (xmlTextReader.Read())
{
if (xmlTextReader.NodeType == XmlNodeType.Element)
lstBox.Items.Add(xmlTextReader.Value);
}
It only returns empty values. I would have expected for example:
first-name element to be Margaret
Thanks