string price="";
string author="";
// initialize dom module
XmlDocument xmldoc = new XmlDocument();
// load xml
xmldoc.Load(books.xml);
XmlNodeList records = xmldoc.GetElementsByTagName("book");
foreach (XmlElement xe in records)
{
XmlElement elmt = (XmlElement)xe;
price= elmt.GetElementsByTagName("price")[0].InnerText;
author= elmt.GetElementsByTagName("author")[0].InnerText;
MessageBox.Show("Author="+author+"==> Price="+price);
}
books.xml
< books >
< price >
< /book >
< book >
< price > 100< /price >
</ book >
< books >
OUT PUT
Author=abc ==> Price=30
Author=xyz==> Price=100
No comments:
Post a Comment