static void krishh_samplexmlread(Args _args)
{
XmlNode root;
XmlNode book;
XmlNodeList books;
XmlNamespaceManager nsmgr;
XmlDocument doc = new XmlDocument();
int i=1;
doc.Load(@"C:\Temp\book.xml");
//Create an XmlNamespaceManager for resolving namespaces.
nsmgr = new XmlNamespaceManager(doc.NameTable());
nsmgr.AddNamespace("bk", "urn:samples");
//Select the book node with the matching attribute value.
root = doc.DocumentElement();
books = root.selectNodes("descendant::book", nsmgr);
for (i = 0; i < books.length(); i++)
{
book = books.item(i);
info(book.selectSingleNode("bk:first-name").text());
info(book.selectSingleNode("bk:last-name").text());
}
}
//<?xml version="1.0"?>
//
//<!-- A fragment of a book store inventory database -->
//
//-<bookstore xmlns:bk="urn:samples">
//
//
//-<book bk:ISBN="1-861001-57-8" publicationdate="1997" genre="novel">
//
//<title>Pride And Prejudice</title>
//
//
//-<author>
//
//<first-name>Jane</first-name>
//
//<last-name>Austen</last-name>
//
//</author>
//
//<price>24.95</price>
//
//</book>
//
//
//-<book bk:ISBN="1-861002-30-1" publicationdate="1992" genre="novel">
//
//<title>The Handmaid's Tale</title>
//
//
//-<author>
//
//<first-name>Margaret</first-name>
//
//<last-name>Atwood</last-name>
//
//</author>
//
//<price>29.95</price>
//
//</book>
//
//
//-<book bk:ISBN="1-861001-57-6" publicationdate="1991" genre="novel">
//
//<title>Emma</title>
//
//
//-<author>
//
//<first-name>Jane</first-name>
//
//<last-name>Austen</last-name>
//
//</author>
//
//<price>19.95</price>
//
//</book>
//-<book bk:ISBN="1-861001-45-3" publicationdate="1982" genre="novel">
//
//<title>Sense and Sensibility</title>
//
//
//-<author>
//
//<first-name>Jane</first-name>
//
//<last-name>Austen</last-name>
//
//</author>
//
//<price>19.95</price>
//
//</book>
//
//</bookstore>
{
XmlNode root;
XmlNode book;
XmlNodeList books;
XmlNamespaceManager nsmgr;
XmlDocument doc = new XmlDocument();
int i=1;
doc.Load(@"C:\Temp\book.xml");
//Create an XmlNamespaceManager for resolving namespaces.
nsmgr = new XmlNamespaceManager(doc.NameTable());
nsmgr.AddNamespace("bk", "urn:samples");
//Select the book node with the matching attribute value.
root = doc.DocumentElement();
books = root.selectNodes("descendant::book", nsmgr);
for (i = 0; i < books.length(); i++)
{
book = books.item(i);
info(book.selectSingleNode("bk:first-name").text());
info(book.selectSingleNode("bk:last-name").text());
}
}
//<?xml version="1.0"?>
//
//<!-- A fragment of a book store inventory database -->
//
//-<bookstore xmlns:bk="urn:samples">
//
//
//-<book bk:ISBN="1-861001-57-8" publicationdate="1997" genre="novel">
//
//<title>Pride And Prejudice</title>
//
//
//-<author>
//
//<first-name>Jane</first-name>
//
//<last-name>Austen</last-name>
//
//</author>
//
//<price>24.95</price>
//
//</book>
//
//
//-<book bk:ISBN="1-861002-30-1" publicationdate="1992" genre="novel">
//
//<title>The Handmaid's Tale</title>
//
//
//-<author>
//
//<first-name>Margaret</first-name>
//
//<last-name>Atwood</last-name>
//
//</author>
//
//<price>29.95</price>
//
//</book>
//
//
//-<book bk:ISBN="1-861001-57-6" publicationdate="1991" genre="novel">
//
//<title>Emma</title>
//
//
//-<author>
//
//<first-name>Jane</first-name>
//
//<last-name>Austen</last-name>
//
//</author>
//
//<price>19.95</price>
//
//</book>
//-<book bk:ISBN="1-861001-45-3" publicationdate="1982" genre="novel">
//
//<title>Sense and Sensibility</title>
//
//
//-<author>
//
//<first-name>Jane</first-name>
//
//<last-name>Austen</last-name>
//
//</author>
//
//<price>19.95</price>
//
//</book>
//
//</bookstore>