『壹』 c#程序怎么读取xml文件
{\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fprq1\fcharset134 \'d0\'c2\'cb\'ce\'cc\'e5;}{\f1\fmodern\fprq6\fcharset134 \'cb\'ce\'cc\'e5;}}{\colortbl ;\red0\green0\blue255;\red128\green128\blue128;\red0\green128\blue0;}{\*\generator Msftedit 5.41.15.1503;}\viewkind4\uc1\pard\cf1\lang2052\f0\fs18 namespace\cf0 XMLWriting \par\par\{ \par\par\tab\cf1 using\cf0 System; \par\par\tab\cf1 using\cf0 System.IO; \par\par\tab\cf1 using\cf0 System.Text; \par\par\tab\cf1 using\cf0 System.Xml; \par\par\tab\cf1 using\cf0 System.Drawing; \par\par\tab\cf1 using\cf0 System.Collections; \par\par\tab\cf1 using\cf0 System.ComponentModel; \par\par\tab\cf1 using\cf0 System.Windows.Forms; \par\par\tab\cf1 using\cf0 System.Data; \par\par\par\par\tab\cf2 ///\cf3 \cf2 <summary>\cf3 \par\par\cf0\tab\cf2 ///\cf3 Form1 \'b5\'c4\'d5\'aa\'d2\'aa\'cb\'b5\'c3\'f7\'a1\'a3 \par\par\cf0\tab\cf2 ///\cf3 \cf2 </summary>\cf3 \par\par\cf0\tab\cf1 public\cf0 \cf1 class\cf0 Form1 : System.Windows.Forms.Form \par\par\tab\{ \par\par\tab\tab\cf1 private\cf0 System.Windows.Forms.TextBox textBox1; \par\par\tab\tab\cf1 private\cf0 System.Windows.Forms.Button button1; \par\par\tab\tab\cf1 private\cf0 System.Windows.Forms.Button button2; \par\par\tab\tab\cf1 private\cf0 System.Windows.Forms.Button button3; \par\par\tab\tab\cf1 private\cf0 System.Windows.Forms.Button button4; \par\par\tab\tab\cf1 private\cf0 System.Windows.Forms.Button button5; \par\par\tab\tab\cf1 private\cf0 System.Windows.Forms.Button button6; \par\par\tab\tab\cf1 private\cf0 System.Windows.Forms.Button button7; \par\par\tab\tab\cf2 ///\cf3 \cf2 <summary>\cf3 \par\par\cf0\tab\tab\cf2 ///\cf3 \'b1\'d8\'d0\'e8\'b5\'c4\'c9\'e8\'bc\'c6\'c6\'f7\'b1\'e4\'c1\'bf\'a1\'a3 \par\par\cf0\tab\tab\cf2 ///\cf3 \cf2 </summary>\cf3 \par\par\cf0\tab\tab\cf1 private\cf0 System.ComponentModel.Container components = \cf1 null\cf0 ; \par\par\par\par\tab\tab\cf1 public\cf0 Form1() \par\par\tab\tab\{ \par\par\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf3 // Windows \'b4\'b0\'cc\'e5\'c9\'e8\'bc\'c6\'c6\'f7\'d6\'a7\'b3\'d6\'cb\'f9\'b1\'d8\'d0\'e8\'b5\'c4 \par\par\cf0\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab InitializeComponent(); \par\par\par\par\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf3 // TODO: \'d4\'da InitializeComponent \'b5\'f7\'d3\'c3\'ba\'f3\'cc\'ed\'bc\'d3\'c8\'ce\'ba\'ce\'b9\'b9\'d4\'ec\'ba\'af\'ca\'fd\'b4\'fa\'c2\'eb \par\par\cf0\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\} \par\par\par\par\tab\tab\cf2 ///\cf3 \cf2 <summary>\cf3 \par\par\cf0\tab\tab\cf2 ///\cf3 \'c7\'e5\'c0\'ed\'cb\'f9\'d3\'d0\'d5\'fd\'d4\'da\'ca\'b9\'d3\'c3\'b5\'c4\'d7\'ca\'d4\'b4\'a1\'a3 \par\par\cf0\tab\tab\cf2 ///\cf3 \cf2 </summary>\cf3 \par\par\cf0\tab\tab\cf1 protected\cf0 \cf1 override\cf0 \cf1 void\cf0 Dispose( \cf1 bool\cf0 disposing ) \par\par\tab\tab\{ \par\par\tab\tab\tab\cf1 if\cf0 ( disposing ) \par\par\tab\tab\tab\{ \par\par\tab\tab\tab\tab\cf1 if\cf0 (components != \cf1 null\cf0 ) \par\par\tab\tab\tab\tab\{ \par\par\tab\tab\tab\tab\tab components.Dispose(); \par\par\tab\tab\tab\tab\} \par\par\tab\tab\tab\} \par\par\tab\tab\tab\cf1 base\cf0 .Dispose( disposing ); \par\par\tab\tab\} \par\par\par\par\cf1\tab\tab #region\cf0 Windows \'b4\'b0\'cc\'e5\'c9\'e8\'bc\'c6\'c6\'f7\'c9\'fa\'b3\'c9\'b5\'c4\'b4\'fa\'c2\'eb \par\par\tab\tab\cf2 ///\cf3 \cf2 <summary>\cf3 \par\par\cf0\tab\tab\cf2 ///\cf3 \'c9\'e8\'bc\'c6\'c6\'f7\'d6\'a7\'b3\'d6\'cb\'f9\'d0\'e8\'b5\'c4\'b7\'bd\'b7\'a8 – \'b2\'bb\'d2\'aa\'ca\'b9\'d3\'c3\'b4\'fa\'c2\'eb\'b1\'e0\'bc\'ad\'c6\'f7\'d0\'de\'b8\'c4 \par\par\cf0\tab\tab\cf2 ///\cf3 \'b4\'cb\'b7\'bd\'b7\'a8\'b5\'c4\'c4\'da\'c8\'dd\'a1\'a3 \par\par\cf0\tab\tab\cf2 ///\cf3 \cf2 </summary>\cf3 \par\par\cf0\tab\tab\cf1 private\cf0 \cf1 void\cf0 InitializeComponent() \par\par\tab\tab\{ \par\par\tab\tab\tab\cf1 this\cf0 .textBox1 = \cf1 new\cf0 System.Windows.Forms.TextBox(); \par\par\tab\tab\tab\cf1 this\cf0 .button1 = \cf1 new\cf0 System.Windows.Forms.Button(); \par\par\tab\tab\tab\cf1 this\cf0 .button2 = \cf1 new\cf0 System.Windows.Forms.Button(); \par\par\tab\tab\tab\cf1 this\cf0 .button3 = \cf1 new\cf0 System.Windows.Forms.Button(); \par\par\tab\tab\tab\cf1 this\cf0 .button4 = \cf1 new\cf0 System.Windows.Forms.Button(); \par\par\tab\tab\tab\cf1 this\cf0 .button5 = \cf1 new\cf0 System.Windows.Forms.Button(); \par\par\tab\tab\tab\cf1 this\cf0 .button6 = \cf1 new\cf0 System.Windows.Forms.Button(); \par\par\tab\tab\tab\cf1 this\cf0 .button7 = \cf1 new\cf0 System.Windows.Forms.Button(); \par\par\tab\tab\tab\cf1 this\cf0 .SuspendLayout(); \par\par\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf3 // textBox1 \par\par\cf0\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf1 this\cf0 .textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) \par\par\tab\tab\tab\tab | System.Windows.Forms.AnchorStyles.Left) \par\par\tab\tab\tab\tab | System.Windows.Forms.AnchorStyles.Right))); \par\par\tab\tab\tab\cf1 this\cf0 .textBox1.Location = \cf1 new\cf0 System.Drawing.Point(0, 8); \par\par\tab\tab\tab\cf1 this\cf0 .textBox1.Multiline = \cf1 true\cf0 ; \par\par\tab\tab\tab\cf1 this\cf0 .textBox1.Name = "textBox1"; \par\par\tab\tab\tab\cf1 this\cf0 .textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both; \par\par\tab\tab\tab\cf1 this\cf0 .textBox1.Size = \cf1 new\cf0 System.Drawing.Size(784, 332); \par\par\tab\tab\tab\cf1 this\cf0 .textBox1.TabIndex = 0; \par\par\tab\tab\tab\cf1 this\cf0 .textBox1.Text = ""; \par\par\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf3 // button1 \par\par\cf0\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf1 this\cf0 .button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); \par\par\tab\tab\tab\cf1 this\cf0 .button1.Location = \cf1 new\cf0 System.Drawing.Point(0, 344); \par\par\tab\tab\tab\cf1 this\cf0 .button1.Name = "button1"; \par\par\tab\tab\tab\cf1 this\cf0 .button1.TabIndex = 1; \par\par\tab\tab\tab\cf1 this\cf0 .button1.Text = "Example1"; \par\par\tab\tab\tab\cf1 this\cf0 .button1.Click += \cf1 new\cf0 System.EventHandler(\cf1 this\cf0 .button1_Click); \par\par\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf3 // button2 \par\par\cf0\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf1 this\cf0 .button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); \par\par\tab\tab\tab\cf1 this\cf0 .button2.Location = \cf1 new\cf0 System.Drawing.Point(88, 344); \par\par\tab\tab\tab\cf1 this\cf0 .button2.Name = "button2"; \par\par\tab\tab\tab\cf1 this\cf0 .button2.TabIndex = 2; \par\par\tab\tab\tab\cf1 this\cf0 .button2.Text = "Example2"; \par\par\tab\tab\tab\cf1 this\cf0 .button2.Click += \cf1 new\cf0 System.EventHandler(\cf1 this\cf0 .button2_Click); \par\par\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf3 // button3 \par\par\cf0\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf1 this\cf0 .button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); \par\par\tab\tab\tab\cf1 this\cf0 .button3.Location = \cf1 new\cf0 System.Drawing.Point(176, 344); \par\par\tab\tab\tab\cf1 this\cf0 .button3.Name = "button3"; \par\par\tab\tab\tab\cf1 this\cf0 .button3.TabIndex = 3; \par\par\tab\tab\tab\cf1 this\cf0 .button3.Text = "WriteNode"; \par\par\tab\tab\tab\cf1 this\cf0 .button3.Click += \cf1 new\cf0 System.EventHandler(\cf1 this\cf0 .button3_Click); \par\par\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf3 // button4 \par\par\cf0\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf1 this\cf0 .button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); \par\par\tab\tab\tab\cf1 this\cf0 .button4.Location = \cf1 new\cf0 System.Drawing.Point(264, 344); \par\par\tab\tab\tab\cf1 this\cf0 .button4.Name = "button4"; \par\par\tab\tab\tab\cf1 this\cf0 .button4.TabIndex = 4; \par\par\tab\tab\tab\cf1 this\cf0 .button4.Text = "Example3"; \par\par\tab\tab\tab\cf1 this\cf0 .button4.Click += \cf1 new\cf0 System.EventHandler(\cf1 this\cf0 .button4_Click); \par\par\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf3 // button5 \par\par\cf0\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf1 this\cf0 .button5.Location = \cf1 new\cf0 System.Drawing.Point(352, 344); \par\par\tab\tab\tab\cf1 this\cf0 .button5.Name = "button5"; \par\par\tab\tab\tab\cf1 this\cf0 .button5.TabIndex = 5; \par\par\tab\tab\tab\cf1 this\cf0 .button5.Text = "Example4"; \par\par\tab\tab\tab\cf1 this\cf0 .button5.Click += \cf1 new\cf0 System.EventHandler(\cf1 this\cf0 .button5_Click); \par\par\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf3 // button6 \par\par\cf0\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf1 this\cf0 .button6.Location = \cf1 new\cf0 System.Drawing.Point(440, 344); \par\par\tab\tab\tab\cf1 this\cf0 .button6.Name = "button6"; \par\par\tab\tab\tab\cf1 this\cf0 .button6.TabIndex = 6; \par\par\tab\tab\tab\cf1 this\cf0 .button6.Text = "Example5"; \par\par\tab\tab\tab\cf1 this\cf0 .button6.Click += \cf1 new\cf0 System.EventHandler(\cf1 this\cf0 .button6_Click); \par\par\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf3 // button7 \par\par\cf0\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf1 this\cf0 .button7.Location = \cf1 new\cf0 System.Drawing.Point(528, 344); \par\par\tab\tab\tab\cf1 this\cf0 .button7.Name = "button7"; \par\par\tab\tab\tab\cf1 this\cf0 .button7.TabIndex = 7; \par\par\tab\tab\tab\cf1 this\cf0 .button7.Text = "Example6"; \par\par\tab\tab\tab\cf1 this\cf0 .button7.Click += \cf1 new\cf0 System.EventHandler(\cf1 this\cf0 .button7_Click); \par\par\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf3 // Form1 \par\par\cf0\tab\tab\tab\cf3 // \par\par\cf0\tab\tab\tab\cf1 this\cf0 .AutoScaleBaseSize = \cf1 new\cf0 System.Drawing.Size(6, 14); \par\par\tab\tab\tab\cf1 this\cf0 .ClientSize = \cf1 new\cf0 System.Drawing.Size(784, 373); \par\par\tab\tab\tab\cf1 this\cf0 .Controls.Add(\cf1 this\cf0 .button7); \par\par\tab\tab\tab\cf1 this\cf0 .Controls.Add(\cf1 this\cf0 .button6); \par\par\tab\tab\tab\cf1 this\cf0 .Controls.Add(\cf1 this\cf0 .button5); \par\par\tab\tab\tab\cf1 this\cf0 .Controls.Add(\cf1 this\cf0 .button4); \par\par\tab\tab\tab\cf1 this\cf0 .Controls.Add(\cf1 this\cf0 .button3); \par\par\tab\tab\tab\cf1 this\cf0 .Controls.Add(\cf1 this\cf0 .button2); \par\par\tab\tab\tab\cf1 this\cf0 .Controls.Add(\cf1 this\cf0 .button1); \par\par\tab\tab\tab\cf1 this\cf0 .Controls.Add(\cf1 this\cf0 .textBox1); \par\par\tab\tab\tab\cf1 this\cf0 .Name = "Form1"; \par\par\tab\tab\tab\cf1 this\cf0 .Text = "XMLWriting"; \par\par\tab\tab\tab\cf1 this\cf0 .ResumeLayout(\cf1 false\cf0 ); \par\par\par\par\tab\tab\} \par\par\cf1\tab\tab #endregion\cf0 \par\par\par\par\tab\tab\cf2 ///\cf3 \cf2 <summary>\cf3 \par\par\cf0\tab\tab\cf2 ///\cf3 \'d3\'a6\'d3\'c3\'b3\'cc\'d0\'f2\'b5\'c4\'d6\'f7\'c8\'eb\'bf\'da\'b5\'e3\'a1\'a3 \par\par\cf0\tab\tab\cf2 ///\cf3 \cf2 </summary>\cf3 \par\par\cf0\tab\tab [STAThread] \par\par\tab\tab\cf1 static\cf0 \cf1 void\cf0 Main() \par\par\tab\tab\{ \par\par\tab\tab\tab Application.Run(\cf1 new\cf0 Form1()); \par\par\tab\tab\} \par\par\par\par\tab\tab\cf1 private\cf0 \cf1 void\cf0 button1_Click(\cf1 object\cf0 sender, System.EventArgs e) \par\par\tab\tab\{ \par\par\tab\tab\tab\cf1 this\cf0 .textBox1.Text = \cf1 string\cf0 .Empty; \par\par\tab\tab\tab\cf1 const\cf0 \cf1 string\cf0 fileName = "WriteXml.xml"; \par\par\par\par\tab\tab\tab XmlTextWriter xmlTxtWt = \cf1 new\cf0 XmlTextWriter(fileName,Encoding.UTF8); \par\par\par\par\tab\tab\tab\cf3 // \'d0\'b4XML\'ce\'c4\'b5\'b5\'c9\'f9\'c3\'f7 \par\par\cf0\tab\tab\tab xmlTxtWt.WriteStartDocument(); \par\par\tab\tab\tab\cf3 // \'d0\'b4XML\'c6\'f0\'ca\'bc\'d4\'aa\'cb\'d8 \par\par\cf0\tab\tab\tab xmlTxtWt.WriteStartElement("ct","ContactDetails","http://www.deltabis.com/Contact"); \par\par\tab\tab\tab\cf3 // \'d0\'b4\'ce\'c4\'b1\'be \par\par\cf0\tab\tab\tab xmlTxtWt.WriteString("This is a XML file"); \par\par\tab\tab\tab\cf3 // \'d0\'b4XML\'bd\'e1\'ca\'f8\'d4\'aa\'cb\'d8 \par\par\cf0\tab\tab\tab xmlTxtWt.WriteEndElement(); \par\par\tab\tab\tab\cf3 // \'d0\'b4\'b9\'d8\'b1\'d5\'ce\'c4\'b5\'b5\'d4\'aa\'cb\'d8 \par\par\cf0\tab\tab\tab xmlTxtWt.WriteEndDocument(); \par\par\par\par\tab\tab\tab xmlTxtWt.Flush(); \cf3 //\'cb\'a2\'d0\'c2 \par\par\cf0\tab\tab\tab xmlTxtWt.Close(); \par\par\par\par\tab\tab\tab\cf1 this\cf0 .textBox1.Text = ReadXml(fileName); \par\par\tab\tab\} \par\par\par\par\tab\tab\cf2 ///\cf3 \cf2 <summary>\cf3 \par\par\cf0\tab\tab\cf2 ///\cf3 \'b6\'c1\'c8\'a1\'be\'ad\'b9\'fd\'b1\'e0\'d0\'b4\'b5\'c4XML\'ce\'c4\'bc\'fe\'b5\'c4\'cb\'f9\'d3\'d0\'c4\'da\'c8\'dd \par\par\cf0\tab\tab\cf2 ///\cf3 \cf2 </summary>\cf3 \par\par\cf0\tab\tab\cf2 ///\cf3 \cf2 <param name="xmlPath">\cf3\'ce\'c4\'bc\'fe\'c2\'b7\'be\'b6\cf2 </param>\cf3 \par\par\cf0\tab\tab\cf2 ///\cf3 \cf2 <returns>\cf3\'b1\'ed\'ca\'be\'c4\'da\'c8\'dd\'b5\'c4\'d7\'d6\'b7\'fb\'b4\'ae\cf2 </returns>\cf3 \par\par\cf0\tab\tab\cf1 private\cf0 \cf1 string\cf0 ReadXml(\cf1 string\cf0 xmlPath) \par\par\tab\tab\{ \par\par\tab\tab\tab\cf1 string\cf0 xmlStr = \cf1 string\cf0 .Empty; \par\par\tab\tab\tab XmlTextReader xmlTxtRd = \cf1 new\cf0 XmlTextReader(xmlPath); \par\par\par\par\tab\tab\tab xmlTxtRd.MoveToContent(); \par\par\tab\tab\tab xmlStr = xmlTxtRd.ReadOuterXml(); \par\par\par\par\tab\tab\tab xmlTxtRd.Close(); \par\par\tab\tab\tab\cf1 return\cf0 xmlStr; \par\par\tab\tab\} \par\par\par\par\tab\tab\cf1 private\cf0 \cf1 void\cf0 button2_Click(\cf1 object\cf0 sender, System.EventArgs e) \par\par\tab\tab\{ \par\par\tab\tab\tab\cf1 this\cf0 .textBox1.Text = \cf1 string\cf0 .Empty; \par\par\tab\tab\tab\cf1 const\cf0 \cf1 string\cf0 fileName = "WriteXml1.xml"; \par\par\par\par\tab\tab\tab XmlTextWriter xmlTxtWt = \cf1 new\cf0 XmlTextWriter(fileName,Encoding.UTF8); \par\par\par\par\tab\tab\tab\cf3 // \'c9\'e8\'d6\'c3XML\'b5\'c4\'ca\'e4\'b3\'f6\'b8\'f1\'ca\'bd\'a3\'ac\'d5\'e2\'c0\'ef\'ca\'b9\'d3\'c3\'cb\'f5\'bd\'f8 \par\par\cf0\tab\tab\tab xmlTxtWt.Formatting = Formatting.Indented; \par\par\tab\tab\tab\cf3 // \'c9\'e8\'d6\'c3\'cb\'f5\'bd\'f8\'b5\'c4\'ca\'fd\'c1\'bf\'a3\'ac\'d5\'e2\'c0\'ef\'ca\'c74\'b8\'f6\'bf\'d5\'b8\'f1\'a3\'acIndentChar\'ca\'f4\'d0\'d4\'c4\'ac\'c8\'cf\'ca\'c7\'bf\'d5\'b8\'f1 \par\par\cf0\tab\tab\tab xmlTxtWt.Indentation = 4; \par\par\par\par\tab\tab\tab xmlTxtWt.WriteStartDocument(); \par\par\tab\tab\tab xmlTxtWt.WriteStartElement("ct","ContactDetails","http://www.deltabis.com/Contact"); \par\par\tab\tab\tab xmlTxtWt.WriteAttributeString("Date","20050121 14:00"); \par\par\tab\tab\tab xmlTxtWt.WriteElementString("contact","abcd"); \par\par\tab\tab\tab xmlTxtWt.WriteElementString("contact","efgh"); \par\par\tab\tab\tab xmlTxtWt.WriteElementString("contact","ijkl"); \par\par\tab\tab\tab xmlTxtWt.WriteElementString("contact","mnop"); \par\par\tab\tab\tab xmlTxtWt.WriteEndElement(); \par\par\tab\tab\tab xmlTxtWt.WriteEndDocument(); \par\par\par\par\tab\tab\tab xmlTxtWt.Flush(); \par\par\tab\tab\tab xmlTxtWt.Close(); \par\par\par\par\tab\tab\tab\cf1 this\cf0 .textBox1.Text = ReadXml(fileName); \par\par\tab\tab\} \par\par\par\par\tab\tab\cf3 // \'b4\'d3\'b6\'c1\'c8\'a1\'c6\'f7\'d6\'d0\'b8\'b4\'d6\'c6\'bd\'da\'b5\'e3\'bc\'b0\'c6\'e4\'c4\'da\'c8\'dd \par\par\cf0\tab\tab\cf1 private\cf0 \cf1 void\cf0 button3_Click(\cf1 object\cf0 sender, System.EventArgs e) \par\par\tab\tab\{ \par\par\tab\tab\tab XmlTextReader xmlTxtRd = \cf1 new\cf0 XmlTextReader("TO_Buaa.xml"); \par\par\tab\tab\tab XmlTextWriter xmlTxtWt = \cf1 new\cf0 XmlTextWriter("WriteXml2.xml",Encoding.UTF8); \par\par\par\par\tab\tab\tab xmlTxtWt.Formatting = Formatting.Indented; \par\par\tab\tab\tab xmlTxtWt.Indentation = 4; \par\par\tab\tab\tab xmlTxtWt.WriteStartDocument(); \par\par\tab\tab\tab xmlTxtWt.WriteComment("\'d2\'d4\'cf\'c2\'ca\'c7\'b4\'d3\'b6\'c1\'c8\'a1\'c6\'f7\'d6\'d0\'bf\'bd\'b1\'b4\'b5\'c4\'bd\'da\'b5\'e3"); \par\par\par\par\tab\tab\tab\cf1 try\cf0 \par\par\tab\tab\tab\{ \par\par\tab\tab\tab\tab\cf1 while\cf0 (xmlTxtRd.Read()) \par\par\tab\tab\tab\tab\{ \par\par\tab\tab\tab\tab\tab\cf1 if\cf0 (xmlTxtRd.NodeType == XmlNodeType.Element) \par\par\tab\tab\tab\tab\tab\tab xmlTxtWt.WriteNode(xmlTxtRd,\cf1 true\cf0 ); \par\par\tab\tab\tab\tab\} \par\par\tab\tab\tab\} \par\par\tab\tab\tab\cf1 catch\cf0 (Exception exp) \par\par\tab\tab\tab\{ \par\par\tab\tab\tab\tab MessageBox.Show(exp.ToString()); \par\par\tab\tab\tab\} \par\par\tab\tab\tab\cf1 finally\cf0 \par\par\tab\tab\tab\{ \par\par\tab\tab\tab\tab xmlTxtWt.Flush(); \par\par\tab\tab\tab\tab xmlTxtWt.Close(); \par\par\tab\tab\tab\tab xmlTxtRd.Close(); \par\par\tab\tab\tab\} \par\par\par\par\tab\tab\tab\cf1 this\cf0 .textBox1.Text = ReadXml("WriteXml2.xml"); \par\par\tab\tab\} \par\par\par\par\tab\tab\cf3 // \'b1\'e0\'d0\'b4\'d2\'bb\'b7\'dd\'cd\'ea\'d5\'fb\'b5\'c4XML \par\par\cf0\tab\tab\cf1 private\cf0 \cf1 void\cf0 button4_Click(\cf1 object\cf0 sender, System.EventArgs e) \par\par\tab\tab\{ \par\par\tab\tab\tab\cf1 this\cf0 .textBox1.Text = \cf1 string\cf0 .Empty; \par\par\tab\tab\tab\cf1 string\cf0 fileName = "WriteXml3.xml"; \par\par\par\par\tab\tab\tab XmlTextWriter xmlTxtWt = \cf1 new\cf0 XmlTextWriter(fileName,Encoding.UTF8); \par\par\par\par\tab\tab\tab xmlTxtWt.Formatting = Formatting.Indented; \par\par\tab\tab\tab xmlTxtWt.Indentation = 4; \par\par\par\par\tab\tab\tab xmlTxtWt.WriteStartDocument(); \par\par\tab\tab\tab xmlTxtWt.WriteStartElement("ct","ContactDetails","http://www.deltabis.com/Contact"); \par\par\tab\tab\tab xmlTxtWt.WriteAttributeString("Date","20050121 16:00"); \par\par\tab\tab\tab xmlTxtWt.WriteComment("This document contains contact information."); \par\par\tab\tab\tab xmlTxtWt.WriteStartElement("contact"); \par\par\tab\tab\tab xmlTxtWt.WriteAttributeString("title",\cf1 string\cf0 .Empty); \par\par\tab\tab\tab xmlTxtWt.WriteStartElement("name"); \par\par\tab\tab\tab xmlTxtWt.WriteElementString("firstname","Steven"); \par\par\tab\tab\tab xmlTxtWt.WriteElementString("middle",\cf1 string\cf0 .Empty); \par\par\tab\tab\tab xmlTxtWt.WriteElementString("lastname","LivingStone-Perez"); \par\par\tab\tab\tab xmlTxtWt.WriteFullEndElement(); \par\par\tab\tab\tab xmlTxtWt.WriteFullEndElement(); \par\par\tab\tab\tab xmlTxtWt.WriteFullEndElement(); \par\par\tab\tab\tab xmlTxtWt.WriteEndDocument(); \par\par\par\par\tab\tab\tab xmlTxtWt.Flush(); \par\par\tab\tab\tab xmlTxtWt.Close(); \par\par\par\par\tab\tab\tab\cf1 this\cf0 .textBox1.Text = ReadXml(fileName); \par\par\tab\tab\} \par\par\par\par\tab\tab\cf3 // \'cc\'ed\'bc\'d3CDATA\'ca\'fd\'be\'dd\'bf\'e9 \par\par\cf0\ta
『贰』 在c#的winform 下怎么读取 xml文件中的数据
C#读取XML文件在5个步骤//1、创建XmlDocument对象XmlDocumentxmlDoc=newXmlDocument();//2、加载源文件xmlDoc.Load("文件名.xml");//3、获取根结点XmlElementxmlRoot=xmlDoc.DocumentElement;//4、获取根结点下的子节点foreach(XmlNodenodeinxmlRoot.ChildNodes){//5、获取子节点对应的内容stringname=node["name"].InnerText;}
『叁』 用C语言读取xml文件,怎么实现
我上次才给人写过xml文件内容<?xmlversion="1.0"encoding="UTF-8"?>-<aicomoa_response>-<country_list>-<country><id>7</id><pid>0</pid><continent_id>1</continent_id><guohao>93</guohao><cntitle>阿富汗</cntitle><entitle>Afghanistan</entitle><hztitle>阿富汗</hztitle><jptitle>アフガニスタン</jptitle><kotitle>??????</kotitle><jp_pinyin>ア</jp_pinyin><pinyin>AFuHan</pinyin><sid>0</sid><jibie>1</jibie></country>-<country><id>8</id><pid>0</pid><continent_id>2</continent_id><guohao>355</guohao><cntitle>阿尔巴尼亚</cntitle><entitle>Albania</entitle><hztitle>阿尔巴尼亚</hztitle><jptitle>アルバニア</jptitle><kotitle/><jp_pinyin>ア</jp_pinyin><pinyin>AErBaNiYa</pinyin><sid>0</sid><jibie>1</jibie></country></country_list></aicomoa_response>运行结果Info[0]=[id:7|pid:0|continent_id:1|guohao:93|cntitle:阿富汗|entitle:Afghanistan|hztitle:阿富汗|jptitle:アフガニスタン|kotitle:??????|jp_pinyin:ア|pinyin:AFuHan|sid:0|jibie:1|]Info[1]=[id:7|pid:0|continent_id:1|guohao:93|cntitle:阿富汗|entitle:Afghanistan|hztitle:阿富汗|jptitle:アフガニスタン|kotitle:??????|jp_pinyin:ア|pinyin:AFuHan|sid:0|jibie:1|]Pressanykeytocontinue代码#include<stdio.h>#include<string.h>main(){inti=0;FILE*fp;charszFileBuff[1024]={0},szBuff[100][1024];charid[10]={0},pid[10]={0},continent_id[10]={0},guohao[10]={0},cntitle[64]={0},entitle[64]={0},hztitle[64]={0},jptitle[64]={0},kotitle[64]={0},jp_pinyin[64]={0},pinyin[64]={0},sid[10]={0},jibie[10]={0};char*lFirst,*lEnd;fp=fopen("country.txt","r");if(fp==NULL){printf("readXMLfileerror!");}while(fgets(szFileBuff,1023,fp)){if((lFirst=strstr(szFileBuff,"<id>"))!=NULL){lEnd=strstr(lFirst+1,"</id>");memcpy(id,lFirst+4,lEnd-lFirst-4);}if((lFirst=strstr(szFileBuff,"<pid>"))!=NULL){lEnd=strstr(lFirst+1,"</pid>");memcpy(pid,lFirst+5,lEnd-lFirst-5);}if((lFirst=strstr(szFileBuff,"<continent_id>"))!=NULL){lEnd=strstr(lFirst+1,"</continent_id>");memcpy(continent_id,lFirst+14,lEnd-lFirst-14);}if((lFirst=strstr(szFileBuff,"<guohao>"))!=NULL){lEnd=strstr(lFirst+1,"</guohao>");memcpy(guohao,lFirst+8,lEnd-lFirst-8);}if((lFirst=strstr(szFileBuff,"<cntitle>"))!=NULL){lEnd=strstr(lFirst+1,"</cntitle>");memcpy(cntitle,lFirst+9,lEnd-lFirst-9);}if((lFirst=strstr(szFileBuff,"<entitle>"))!=NULL){lEnd=strstr(lFirst+1,"</entitle>");memcpy(entitle,lFirst+9,lEnd-lFirst-9);}if((lFirst=strstr(szFileBuff,"<hztitle>"))!=NULL){lEnd=strstr(lFirst+1,"</hztitle>");memcpy(hztitle,lFirst+9,lEnd-lFirst-9);}if((lFirst=strstr(szFileBuff,"<jptitle>"))!=NULL){lEnd=strstr(lFirst+1,"</jptitle>");memcpy(jptitle,lFirst+9,lEnd-lFirst-9);}if((lFirst=strstr(szFileBuff,"<kotitle>"))!=NULL){lEnd=strstr(lFirst+1,"</kotitle>");memcpy(kotitle,lFirst+9,lEnd-lFirst-9);}if((lFirst=strstr(szFileBuff,"<jp_pinyin>"))!=NULL){lEnd=strstr(lFirst+1,"</jp_pinyin>");memcpy(jp_pinyin,lFirst+11,lEnd-lFirst-11);}if((lFirst=strstr(szFileBuff,"<pinyin>"))!=NULL){lEnd=strstr(lFirst+1,"</pinyin>");memcpy(pinyin,lFirst+8,lEnd-lFirst-8);}if((lFirst=strstr(szFileBuff,"<sid>"))!=NULL){lEnd=strstr(lFirst+1,"</sid>");memcpy(sid,lFirst+5,lEnd-lFirst-5);}if((lFirst=strstr(szFileBuff,"<jibie>"))!=NULL){lEnd=strstr(lFirst+1,"</jibie>");memcpy(jibie,lFirst+7,lEnd-lFirst-7);}if((lFirst=strstr(szFileBuff,"</country>"))!=NULL){sprintf(szBuff[i],"id:%s|pid:%s|continent_id:%s|guohao:%s|cntitle:%s|entitle:%s|hztitle:%s|jptitle:%s|kotitle:%s|jp_pinyin:%s|pinyin:%s|sid:%s|jibie:%s|",id,pid,continent_id,guohao,cntitle,entitle,hztitle,jptitle,kotitle,jp_pinyin,pinyin,sid,jibie);printf("Info[%d]=[%s]",i++,szBuff);}}fclose(fp);}
『肆』 C语言 如何读取xml文件中的数据并存入一个结构体中
利用com、用xml的dll就可以了,不多说了,具体再不懂再问我把。我工作也有解析xml文件的 呵呵
『伍』 使用c#如何读取xml文件
XmlReader和XmlTextReader类定义在System.XML名字空间中。XmlTextReader类源于XmlReader类。XmlTextReader类可用来读取XML文档。此类的Read方法读取此文档,直到其节点结束。在这篇文章里,将演示如何使用XmlTextReader类来读取一个XML文档及输出数据到控制台。加入名字空间引用因为Xml类都定义在System.Xml名字空间当中,所以首先要做的是在工程里加入对System.Xml的引用。using System.Xml;打开一个XML文档XmlTextReader类的构造器打开一个XML文件。在这个例子里使用了一个名为xmltest.xml的文件,它保存在C:\temp目录当中。你可以下载此附件。// 打开一个 XML 文件 XmlTextReader reader = new XmlTextReader("C:\\temp\\xmltest.xml");读取数据XmlTextReader类的Read方法读取数据。while ( reader.Read() ){Console.WriteLine(reader.Name);}源代码:附件CS CodeXML文件namespace ReadXML { using System; using System.Xml; public static int Main(string[] args) { try { // 打开一个 XML 文件 XmlTextReader reader = new XmlTextReader("C:\\temp\\xmltest.xml"); while ( reader.Read() ) { Console.WriteLine(reader.Name); } } catch (Exception e) { Console.WriteLine ("Exception: {0}", e.ToString()); } return 0; } } }
『陆』 C#怎样读取XML文件中的指定值
两种方式: 1、使用xmldocument类加载这个xml,然后调用其成员函数查找你要的节点。 2、在vs中打开这个xml文件,在xml菜单中选择生成架构,将这个xsd保存为文件a.xsd,然后进入vs的命令行,进入a.xsd目录,调用“xsd.exe /c /n:MyNamespace a.xs
『柒』 用C语言读写xml文件
都是文本格式的,我想与读txt的区别在于两种文件的组织方式不一样而已,xml应该理解为受一种格式限制的文本文件,按照这些格式多做一些逻辑处理就行吧
『捌』 如何从文件中读取 XML,使用 C
/**/ /// <summary> /// XML 操作基类 /// </summary> public class XmlHelper { /**/ /// <summary> /// 读取Xml到DataSet中 /// </summary> /// <param name="XmlPath">路径</param> /// <returns>结果集</returns> public static DataSet GetXml(string XmlPath) { DataSet ds = new DataSet(); ds.ReadXml(@XmlPath); return ds; } /**/ /// <summary> /// 读取xml文档并返回一个节点:适用于一级节点 /// </summary> /// <param name="XmlPath">xml路径</param> /// <param name="NodeName">节点</param> /// <returns></returns> public static string ReadXmlReturnNode(string XmlPath, string Node) { XmlDocument docXml = new XmlDocument(); docXml.Load(@XmlPath); XmlNodeList xn = docXml.GetElementsByTagName(Node); return xn.Item(0).InnerText.ToString(); } /**/ /// <summary> /// 查找数据,返回当前节点的所有下级节点,填充到一个DataSet中 /// </summary> /// <param name="xmlPath">xml文档路径</param> /// <param name="XmlPathNode">节点的路径:根节点/父节点/当前节点</param> /// <returns></returns> public static DataSet GetXmlData(string xmlPath, string XmlPathNode) { XmlDocument objXmlDoc = new XmlDocument(); objXmlDoc.Load(xmlPath); DataSet ds = new DataSet(); StringReader read = new StringReader(objXmlDoc.SelectSingleNode(XmlPathNode).OuterXml); ds.ReadXml(read); return ds; } /**/ /// <summary> /// 更新Xml节点内容 /// </summary> /// <param name="xmlPath">xml路径</param> /// <param name="Node">要更换内容的节点:节点路径 根节点/父节点/当前节点</param> /// <param name="Content">新的内容</param> public static void XmlNodeReplace(string xmlPath, string Node, string Content) { XmlDocument objXmlDoc = new XmlDocument(); objXmlDoc.Load(xmlPath); objXmlDoc.SelectSingleNode(Node).InnerText = Content; objXmlDoc.Save(xmlPath); } /**/ /// <summary> /// 更改节点的属性值 /// </summary> /// <param name="xmlPath">文件路径</param> /// <param name="NodePath">节点路径</param> /// <param name="NodeAttribute1">要更改的节点属性的名称</param> /// <param name="NodeAttributeText">更改的属性值</param> public static void XmlAttributeEdit(string xmlPath, string NodePath, string NodeAttribute1, string NodeAttributeText) { XmlDocument objXmlDoc = new XmlDocument(); objXmlDoc.Load(xmlPath); XmlNode nodePath = objXmlDoc.SelectSingleNode(NodePath); XmlElement xe = (XmlElement)nodePath; xe.SetAttribute(NodeAttribute1, NodeAttributeText); objXmlDoc.Save(xmlPath); } /**/ /// <summary> /// 删除XML节点和此节点下的子节点 /// </summary> /// <param name="xmlPath">xml文档路径</param> /// <param name="Node">节点路径</param> public static void XmlNodeDelete(string xmlPath, string Node) { XmlDocument objXmlDoc = new XmlDocument(); objXmlDoc.Load(xmlPath); string mainNode = Node.Substring(0, Node.LastIndexOf("/")); objXmlDoc.SelectSingleNode(mainNode).RemoveChild(objXmlDoc.SelectSingleNode(Node)); objXmlDoc.Save(xmlPath); } /**/ /// <summary> /// 删除一个节点的属性 /// </summary> /// <param name="xmlPath">文件路径</param> /// <param name="NodePath">节点路径(xpath)</param> /// <param name="NodeAttribute">属性名称</param> public static void xmlnNodeAttributeDel(string xmlPath, string NodePath, string NodeAttribute) { XmlDocument objXmlDoc = new XmlDocument(); objXmlDoc.Load(xmlPath); XmlNode nodePath = objXmlDoc.SelectSingleNode(NodePath); XmlElement xe = (XmlElement)nodePath; xe.RemoveAttribute(NodeAttribute); objXmlDoc.Save(xmlPath); } /**/ /// <summary> /// 插入一个节点和此节点的子节点 /// </summary> /// <param name="xmlPath">xml路径</param> /// <param name="MailNode">当前节点路径</param> /// <param name="ChildNode">新插入节点</param> /// <param name="Element">插入节点的子节点</param> /// <param name="Content">子节点的内容</param> public static void XmlInsertNode(string xmlPath, string MailNode, string ChildNode, string Element, string Content) { XmlDocument objXmlDoc = new XmlDocument(); objXmlDoc.Load(xmlPath); XmlNode objRootNode = objXmlDoc.SelectSingleNode(MailNode); XmlElement objChildNode = objXmlDoc.CreateElement(ChildNode); objRootNode.AppendChild(objChildNode); XmlElement objElement = objXmlDoc.CreateElement(Element); objElement.InnerText = Content; objChildNode.AppendChild(objElement); objXmlDoc.Save(xmlPath); } /**/ /// <summary> /// 向一个节点添加属性 /// </summary> /// <param name="xmlPath">xml文件路径</param> /// <param name="NodePath">节点路径</param> /// <param name="NodeAttribute1">要添加的节点属性的名称</param> /// <param name="NodeAttributeText">要添加属性的值</param> public static void AddAttribute(string xmlPath, string NodePath, string NodeAttribute1, string NodeAttributeText) { XmlDocument objXmlDoc = new XmlDocument(); objXmlDoc.Load(xmlPath); XmlAttribute nodeAttribute = objXmlDoc.CreateAttribute(NodeAttribute1); XmlNode nodePath = objXmlDoc.SelectSingleNode(NodePath); nodePath.Attributes.Append(nodeAttribute); XmlElement xe = (XmlElement)nodePath; xe.SetAttribute(NodeAttribute1, NodeAttributeText); objXmlDoc.Save(xmlPath); } /**/ /// <summary> /// 插入一节点,带一属性 /// </summary> /// <param name="xmlPath">Xml文档路径</param> /// <param name="MainNode">当前节点路径</param> /// <param name="Element">新节点</param> /// <param name="Attrib">属性名称</param> /// <param name="AttribContent">属性值</param> /// <param name="Content">新节点值</param> public static void XmlInsertElement(string xmlPath, string MainNode, string Element, string Attrib, string AttribContent, string Content) { XmlDocument objXmlDoc = new XmlDocument(); objXmlDoc.Load(xmlPath); XmlNode objNode = objXmlDoc.SelectSingleNode(MainNode); XmlElement objElement = objXmlDoc.CreateElement(Element); objElement.SetAttribute(Attrib, AttribContent); objElement.InnerText = Content; objNode.AppendChild(objElement); objXmlDoc.Save(xmlPath); } /**/ /// <summary> /// 插入一节点,不带属性 /// </summary> /// <param name="xmlPath">Xml文档路径</param> /// <param name="MainNode">当前节点路径</param> /// <param name="Element">新节点</param> /// <param name="Content">新节点值</param> public static void XmlInsertElement(string xmlPath, string MainNode, string Element, string Content) { XmlDocument objXmlDoc = new XmlDocument(); objXmlDoc.Load(xmlPath); XmlNode objNode = objXmlDoc.SelectSingleNode(MainNode); XmlElement objElement = objXmlDoc.CreateElement(Element); objElement.InnerText = Content; objNode.AppendChild(objElement); objXmlDoc.Save(xmlPath); } /**/ /// <summary> /// 在根节点下添加父节点 /// </summary> public static void AddParentNode(string xmlPath, string parentNode) { XmlDocument xdoc = new XmlDocument(); xdoc.Load(xmlPath); // 创建一个新的menber节点并将它添加到根节点下 XmlElement Node = xdoc.CreateElement(parentNode); xdoc.DocumentElement.PrependChild(Node); xdoc.Save(xmlPath); } /**/ /// <summary> /// 根据节点属性读取子节点值(较省资源模式) /// </summary> /// <param name="XmlPath">xml路径</param> /// <param name="FatherElement">父节点值</param> /// <param name="AttributeName">属性名称</param> /// <param name="AttributeValue">属性值</param> /// <param name="ArrayLength">返回的数组长度</param> /// <returns></returns> public static System.Collections.ArrayList GetSubElementByAttribute(string XmlPath, string FatherElement, string AttributeName, string AttributeValue, int ArrayLength) { System.Collections.ArrayList al = new System.Collections.ArrayList(); XmlDocument docXml = new XmlDocument(); docXml.Load(@XmlPath); XmlNodeList xn; xn = docXml.DocumentElement.SelectNodes("//" + FatherElement + "[" + @AttributeName + "='" + AttributeValue + "']"); XmlNodeList xx = xn.Item(0).ChildNodes; for (int i = 0; i < ArrayLength & i < xx.Count; i++) { al.Add(xx.Item(i).InnerText); } return al; }
『玖』 C#如何读取xml文件内容并用listview控件显示
可读取多行内容,仅供参考1.xml文件内容:<?xmlversion="1.0"encoding="utf-8"?><filesauto><file><type>文件</type><state>√</state><path>C:UsersmirrorDesktop备份资料.txt</path><text>未备份</text></file><file><type>文件</type><state>√</state><path>C:UsersmirrorDesktop待办.txt</path><text>未备份</text></file><folder><type>文件夹</type><state>√</state><path>E:Videos</path><text>未备份</text></folder><folder><type>文件夹</type><state>√</state><path>E:Pictures</path><text>未备份</text></folder></filesauto>2.新建的类publicclassFilesAuto{publicFilesAuto(){}privatestringfileType;publicstringFileType{get{returnfileType;}set{fileType=value;}}privatestringfileState;publicstringFileState{get{returnfileState;}set{fileState=value;}}privatestringfilePath;publicstringFilePath{get{returnfilePath;}set{filePath=value;}}privatestringfileText;publicstringFileText{get{returnfileText;}set{fileText=value;}}}3.读取xml数据到ListView控件中:privatevoidShowXML()//显示xml数据{stringpath="filesAuto.xml";//xml的文件位置XmlDocumentxmlDoc=newXmlDocument();XmlReaderSettingssettings=newXmlReaderSettings();settings.IgnoreComments=true;//忽略xml文档中的注释XmlReaderreader=XmlReader.Create(path,settings);xmlDoc.Load(reader);//读取xml数据XmlNodexn=xmlDoc.SelectSingleNode("filesauto");XmlNodeListxnl=xn.ChildNodes;List<FilesAuto>stsList=newList<FilesAuto>();//循环遍历获取xml文档中的全部数据foreach(XmlNodeXnlinxnl){FilesAutofilesAuto=newFilesAuto();XmlElementxe1=(XmlElement)Xnl;XmlNodeListxnl0=xe1.ChildNodes;filesAuto.FileType=xnl0.Item(0).InnerText;filesAuto.FileState=xnl0.Item(1).InnerText;filesAuto.FilePath=xnl0.Item(2).InnerText;filesAuto.FileText=xnl0.Item(3).InnerText;ListViewItemlist=listView1.Items.Add(filesAuto.FileType);list.SubItems.Add(filesAuto.FileState);list.SubItems.Add(filesAuto.FilePath);list.SubItems.Add(filesAuto.FileText);}reader.Close();//关闭读取流}使用方法:privatevoidButton6_Click(objectsender,EventArgse){ShowXML();}
效果图:
若有不足之处恳请大家指出改正
『拾』 使用c#如何读取xml文件
XmlTextReader类源于XmlReader类。XmlTextReader类可用来读取XML文档。此类的Read方法读取此文档,直到其节点结束。在这篇文章里,将演示如何使用XmlTextReader类来读取一个XML文档及输出数据到控制台。加入名字空间引用因为Xml类都定义在System.Xml名字空间当中,所以首先要做的是在工程里加入对System.Xml的引用。usingSystem.Xml;打开一个XML文档XmlTextReader类的构造器打开一个XML文件。在这个例子里使用了一个名为xmltest.xml的文件,它保存在C:\temp目录当中。你可以下载此附件。
未经允许不得转载:山九号 » c读取xml文件内容|C语言 如何读取xml文件中的数据并存入一个结构体中