C#中用XmlDocument对象获取XML文件中的节点值
xml文件:
<?xml version="1.0" encoding="utf-8" ?>
<bookstore>
<book>
<title lang="eng">Harry Potter</title>
<price>29.99</price>
</book>
<book>
<title lang="eng">Learning XML</title>
<price>39.98</price>
</book>
<bookstore>
<title lang="eng">Learning C#</title>
<price>55.23</price>
</bookstore>
<item name="1">第一个item</item>
<item name="2">
<item name="1">这个结点(1)</item>
<item name="2">这个结点(2)</item>
<book>
<title lang="cn">Learning C</title>
<price>60.95</price>
</book>
</item>
</bookstore>
XmlDocument xdoc = new XmlDocument();
xdoc.Load(Server.MapPath("books.xml"));
XmlNodeList xnl = xdoc.SelectNodes("/bookstore/book");
string nodeTempStr = "";
foreach (XmlNode node in xnl)
{
nodeTempStr = node.InnerText;
node
相关文档:
一直以来读取xml都是通过DataSet的ReadXML方法来解决,其他属性也都没有使用。在数据量小的时候倒也相安无事,直到今天读取一个20M的XML流才发现实在太影响效率了。
默认情况下,ReadXML缺省情况下使用XmlReadMode.Auto方式读取,用以前的作法,由于xml文件里没有包含Scheme,DataSet会先推断xml的结构,然后再加载数据。可 ......
ASP.NET程序中常用的三十三种代码
1. 打开新的窗口并传送参数:
传送参数:
response.write("<script>window.open(’*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)</script>")
接收参数:
string a = Request.QueryString("id");
string& ......
一、引言
如今,在SQL Server 2005中,XML成为第一流的数据类型。借助于基于XML模式的强类型化支持和基于服务器端的XML数据校验功能,现在
,开发者可以对存储的XML文档进行轻松地远程修改。作为数据库开发者,许多人都必须大量地涉及XML。
如今,在SQL Server 2005中,你能以一种新的数据类型的形式把XML存储在数据库中 ......
<?xml version="1.0" encoding="gb2312" ?>
<?xml-stylesheet type="tet/css" href="mystyle.css" ?>
<%@ page errorPage="error.jap" %>
<%@ page contentType="text/xml" %>
<realmarid>
皇马花名册
<athlete>
<name>齐达内</name>
<country> ......