hi all
i am reading XML using XMLTextReader but can't get whole line
my XML is as follows
[CODE]This is test XML yes [/CODE]
when i read
XmlReaderObject.Value then i get only [B]This is text[/B]
but i want whole line as
[B]This is test XML yes [/B]
how can i code it ???
any hint ??
thankx in advance
koolprasad2003:)
Error while reading XML using XMLTextReader
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Niradhip ChakrabortyRank #428 · 5.8K pointsPosted Jun 25, 2009, 10:31 PM EDT
as a different element and it is not giving you the text inside you will get the text inside in next iteration. So you can hold the previous value in string and concatinate with the new value to get the entire string.
Try the following method
Check my xml file:
[B]This is test XML yes [/B]
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
strNodeName = reader.Name;
}
if (reader.NodeType == XmlNodeType.Text)
{
if (strNodeName == "MayPara")
{
strvalue = reader.Value.ToString();
}
if(strNodeName == "b")
{
if((strNodeName !="")
{
strNodeName = strNodeName + reader.Value.ToString();
}
}
}
}
Niradhip ChakrabortyRank #428 · 5.8K pointsPosted Jun 25, 2009, 11:11 PM EDT
instead of use >
Your xml code: This is test XML yes
Revised xml code: This is test <b>XML</b> yes