码迷,mamicode.com
首页 > 其他好文 > 详细

XmlNode.PrependChild 方法

时间:2017-06-09 11:07:34      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:ges   span   com   save   nod   src   out   ons   ice   

using System;
using System.IO;
using System.Xml;

public class Sample {

  public static void Main() {

    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<book genre=‘novel‘ ISBN=‘1-861001-57-5‘>" +
                "<title>Pride And Prejudice</title>" +
                "</book>");

    XmlNode root = doc.DocumentElement;

    //Create a new node.
    XmlElement elem = doc.CreateElement("price");
    elem.InnerText="19.95";

    //Add the node to the document.
    root.PrependChild(elem);

    Console.WriteLine("Display the modified XML...");
    doc.Save(Console.Out);

  }
}

技术分享

XmlNode.PrependChild 方法

标签:ges   span   com   save   nod   src   out   ons   ice   

原文地址:http://www.cnblogs.com/herizai/p/6970778.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!