日期:2014-05-19  浏览次数:20590 次

呵呵,刚接触到C#与xml,所以想请大虾帮忙写个过程,谢谢~~
RT

创建的大致的XML文档格式如下:

<root>
    <person   id= '1 '>
          <name> a </name>
          <height> 173CM </height>
    </person>
    <person   id= '2 '>
          <name> 5 </name>
          <height> 175CM </height>
    </person>
</root>

呵呵,多谢了~~~50分奉上~~~大虾笑纳~~~

------解决方案--------------------
XmlDocument dom = new XmlDocument(); XmlElement root= dom.CreateElement( "root "); dom.AppendChild(root); XmlElement person = dom.CreateElement( "person "); XmlAttribute at = dom.CreateAttribute( "id "); at.Value = "1 "; person.Attributes.Append(at); root.AppendChild(person); XmlElement el = dom.CreateElement( "name "); el.InnerText = "a "; person.AppendChild(el); el = dom.CreateElement( "height "); el.InnerText = "173cm "; person.AppendChild(el); Response.Write(dom.InnerXml);