CS page code
using System;
using System.IO;
using System.Xml;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int bookcount = 0;
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreWhitespace = true;
settings.IgnoreComments = true;
string booksFile = Server.MapPath("books.xml");
using (XmlReader reader = XmlReader.Create(booksFile, settings))
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element &&
"book" == reader.LocalName)
{
bookcount++;
}
}
}
Response.Write(String.Format("Found {0} books!", bookcount));
}
}
books.xml
<?xml version='1.0'?>
<!-- This file is a part of a book store inventory database -->
<bookstore xmlns="http://example.books.com">
<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.19</price>
</book>
<book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>12.99</price>
</book>
<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<first-name>Sidas</first-name>
<last-name>Plato</last-name>
</author>
<price>9.91</price>
</book>
</bookstore>
Author:
Aamir Hasan औथोर:
आमिर हसन أثر
أمير حسن .
bd02928d-dc71-4ec2-b79f-c5a135c6e8de|0|.0
ALL, asp.net, asp.net 4.0, XML
asp.net 4, asp.net, xml