<?xml version="1.0" encoding="utf-8" ?>
<config>
<conn>
<str>sssssssssss</str>
<title>aaaaaaaaa</title>
</conn>
</config>有这样一个文档,名字为config.xml,请大家给出读取str和title的值的代码。谢谢,最好能有注释。
<config>
<conn>
<str>sssssssssss</str>
<title>aaaaaaaaa</title>
</conn>
</config>有这样一个文档,名字为config.xml,请大家给出读取str和title的值的代码。谢谢,最好能有注释。
解决方案 »
- Server Error in '/' Application.
- 怎么记录管理员后台操作的明细
- 视图的查询条件问题
- 菜鸟提问....新手没分..
- 谁用过NauckIT.PostgreSQLProvider.dll?项目需要,共同探讨下
- (一)急!!急!!急!!关于Oracle数据库优化的简单问题,在线等,马上结贴。。。谢谢
- 在前台绑定TextBox的问题
- 从哪下载ASP。net
- 2个listbox的问题
- 请教各位关于 VS2005 数据源控件SqlDataSource配置的问题!
- hyperlink+image控件如何一块应用呀???就是说用IMAGE控制大小,用HYPERLINK做边接???
- ultraWebGrid怎么把新加的记录更新到数据库啊?
using System;
using System.IO;
using System.Xml;public class Sample
{
public static void Main()
{
//Create the XmlDocument.
XmlDocument doc = new XmlDocument();
doc.Load("books.xml"); //Display all the book titles.
XmlNodeList elemList = doc.GetElementsByTagName("title");
for (int i=0; i < elemList.Count; i++)
{
Console.WriteLine(elemList[i].InnerXml);
} }
}
该示例将 books.xml 文件用作输入。
<?xml version='1.0'?>
<!-- This file represents a fragment of a book store inventory database -->
<bookstore>
<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.99</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>11.99</price>
</book>
<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<name>Plato</name>
</author>
<price>9.99</price>
</book>
</bookstore>
document.Load(this.nPath);
XmlNode root = document.FirstChild;
foreach(XmlNode child in root.ChildNodes)
{
if(child.Name == "ServerName")
{
this.Path = child.InnerText.ToString();
}
if(child.Name == "WebUrl")
{
this.WebUrl = child.InnerText.ToString();
}
}
docXml.Load("config.xml");
XmlNodeList configStr = doc.GetElementsByTagName("title");