Possible Duplicate:
How to read XML node from URL using C#?
I'm having below XML, I want to read this XML URL using C#
<result>
<Accounts>
<row no="1">
<FL val="ACCOUNTID">012345678</FL>
<FL val="SMOWNERID">012345678</FL>
<FL val="Account Owner">
<![CDATA[ demo name]]>
</FL>
<FL val="Account Name">
<![CDATA[ demo ]]>
</FL>
<FL val="Phone">
<![CDATA[ +12 34 5567 345]]>
</FL>
<FL val="Account Site">
<![CDATA[ demo]]>
</FL>
I have used below code for reading XML from URL but i'm getting below output in console
<FL val="Account Name">
<![CDATA[ demo ]]>
</FL>
<FL val="Phone">
</FL>
<FL val="Account Site">
</FL>
My code is below :
String xmlURL = "http://localhost/my.xml";
XmlTextReader xmlReader = new XmlTextReader(xmlURL);
while (xmlReader.Read())
{
switch (xmlReader.NodeType)
{
case XmlNodeType.Element: // The node is an element.
Console.Write("<" + xmlReader.Name);
while (xmlReader.MoveToNextAttribute()) // Read the attributes.
Console.Write(" " + xmlReader.Name + "=’" + xmlReader.Value + "’");
Console.WriteLine(">");
break;
case XmlNodeType.Text: //Display the text in each element.
Console.WriteLine(xmlReader.Value);
break;
case XmlNodeType.EndElement: //Display the end of the element.
Console.Write("</" + xmlReader.Name);
Console.WriteLine(">");
break;
}
}
Console.WriteLine("Press any key to continue…");
Console.ReadLine(); //Pause
Please help to read the inside data