Hi nayankumar_msat@hotmail.com
Please see my example below for reading xml (see it working here :
XML read dotNetFiddle[
^]
I hope this helps in getting you started with reading xml.
using System;
using System.Xml;
public class Program
{
private const string TestXml =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<MovieData>" +
"<Movies>" +
"<Movie>" +
"<Id>1</Id>" +
"<Name>Batman</Name>" +
"</Movie>" +
"<Movie>" +
"<Id>2</Id>" +
"<Name>Batman Returns</Name>" +
"</Movie>" +
"<Movie>" +
"<Id>3</Id>" +
"<Name>Batman Dark Knight</Name>" +
"</Movie>" +
"</Movies>" +
"</MovieData>";
public static void Main()
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(TestXml);
string xpath = "MovieData/Movies/Movie";
var nodes = xmlDoc.SelectNodes(xpath);
foreach(XmlNode childrenNode in nodes)
{
Console.WriteLine(
"Movie - Id: " + childrenNode.SelectSingleNode(".//Id").InnerText +
", Name: " + childrenNode.SelectSingleNode(".//Name").InnerText);
}
}
}
The code above outputs:
Movie - Id: 1, Name: Batman
Movie - Id: 2, Name: Batman Returns
Movie - Id: 3, Name: Batman Dark Knight
For xsd querying ang getting data types check this solution:
xml - How to extract Attributes along with their names and datatypes from an XSD file using c# - Stack Overflow[
^]