读取XML节点 - .NET技术 / C#
谁能给个C#中读取XML节点的范例!
XmlDocument pXmlDocument = new XmlDocument();
pXmlDocument.Load(C:\\Config.xml);
XmlNode pDbConnNode = pXmlDocument.SelectSingleNode("ProConfig/Database/Conn");
m_sConn = pDbConnNode.InnerText;
XML code:
Ma Jin Hu 239000 Feng Huang StreetChu Zhou City ANHUI Wang Tian 239000 Lang Ya StreetHe Fei City ANHUI Zou Wen Biao 100000 Sai Di StreetBei Jin CityBei Jin
C# code:
using System ;using System.Drawing ;using System.Collections ;using System.ComponentModel ;using System.Windows.Forms ;using System.Data ;using System.Xml ;public class Form1 : Form{private Button button1 ;private ListView Listview1 ;private System.ComponentModel.Container components = null ;public Form1 ( ){//初始化窗体中的各个组件InitializeComponent ( ) ;}//清除程序中使用过的资源protected override void Dispose ( bool disposing ){if ( disposing ){if ( components != null ) {components.Dispose ( ) ;}}base.Dispose ( disposing ) ;}private void InitializeComponent ( ){button1 = new Button ( ) ;Listview1 = new ListView ( ) ;SuspendLayout ( ) ;button1.Anchor = ( ( AnchorStyles.Bottom | AnchorStyles.Left ) | AnchorStyles.Right ) ;b
相关问答:
txt 和XML 格式相应
不借助DataSet
导入读取TXT文件
然后直接写入XML(同一文件,不同数据,递增原数据没有被覆盖情况下增加数据.)
教个要点或最好是有个代码提示的
过路好汉 帮个忙撒^^
不会,帮楼主 ......
我有一个类似的xml的 string,想通过遍历怎么个xml 输出我想要的element的值
xml 为:
<Discover xmlns="urn:schemas-microsoft-com:xml-analysis">
<RequestType>DISCOVER_XML_ME ......
现在有个xml文件是<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xm ......
思路:要用c#生成一个播放机的播放列表的xml,例如:
<daty datys='2010-04-05' datye='2010-05-01' > //这是播放的日期段
<time times='01:12:00' timee='02:30:00'> ......