but the problem is:
in order to bring "jone" I use : xmlReader.ReadElementString()
but if I now want to bring Name I can't use xmlReader.Name becuase it gives me the next Elemnt - LastName..
How can I read an <...> if I already read the string Element?
batel hodefiPosted Dec 31, 2009, 2:38 PM
I don't want foreach loop..I need to read a line take the string and sometime the element and advance to the next line...
Lalit MPosted Dec 31, 2009, 1:19 PM
http://www.codeproject.com/KB/XML/csreadxml1.aspx
Happy New Year....
Kirtan PatelPosted Dec 31, 2009, 1:15 PM
Here is your solution !!
friend, if my answer helps you than check "Do you like this answer" check box :)
static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
doc.Load("XMLFile1.xml");
foreach (XmlNode node in doc.ChildNodes)
{
if (node.Name == "tok")
{
foreach (XmlNode child in node)
{
Console.WriteLine(child.Name);
//If you want value inside the use below line
//Console.WriteLine(child.InnerText);
}
}
}
Console.ReadKey();
}
Output
-----