zoukankan      html  css  js  c++  java
  • c#之xml

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml;
    using System.IO;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
            //    XmlDocument doc = new XmlDocument();
            //    //创建描述信息,并且添加到doc文档中
            // XmlDeclaration dc=doc.CreateXmlDeclaration("1.0", "utf-8", null);
            // doc.AppendChild(dc);
            // //添加根节点
            // XmlElement nodes = doc.CreateElement("Books");
            // doc.AppendChild(nodes);
            ////添加子节点
            // XmlElement book1 = doc.CreateElement("book");
            // nodes.AppendChild(book1);
            // XmlElement book2 = doc.CreateElement("name");
            // book2.InnerText = "假如sssx";
            // book1.AppendChild(book2);
            
            // XmlElement book3 = doc.CreateElement("price");
            // book1.AppendChild(book3);
            // book3.InnerText = "600";
            // XmlElement book4 = doc.CreateElement("dec");
            // book1.AppendChild(book4);
            // book4.InnerText = "6sdasdsadsad";
    
            // XmlElement book5 = doc.CreateElement("book");
            // nodes.AppendChild(book5);
            // XmlElement book6 = doc.CreateElement("name");
            // book6.InnerText = "假如";
            // book5.AppendChild(book6);
    
            // XmlElement book7 = doc.CreateElement("price");
            // book5.AppendChild(book7);
            // book7.InnerText = "60";
            // XmlElement book8 = doc.CreateElement("dec");
            // book5.AppendChild(book8);
            // book8.InnerText = "6sdasdsadsad";
          
            // doc.Save("kiven.xml");
               
            // Console.ReadKey();
                XmlDocument doc = new XmlDocument();
                XmlDeclaration dc = doc.CreateXmlDeclaration("1.0", "utf-8", "yes");
                doc.AppendChild(dc);
                XmlElement order = doc.CreateElement("Order");
                doc.AppendChild(order);
                XmlElement Cu = doc.CreateElement("CustomerName");
                order.AppendChild(Cu);
                Cu.InnerText = "张三";
                XmlElement cust=doc.CreateElement("customerNumber1");
                cust.InnerText = "100";
                order.AppendChild(cust);
                XmlElement item = doc.CreateElement("Items");
                order.AppendChild(item);
                XmlElement orders = doc.CreateElement("OrderItem");
                orders.SetAttribute("Name", "码表");
                orders.SetAttribute("Count", "20");
                item.AppendChild(orders);
                XmlElement orders1 = doc.CreateElement("OrderItem");
                item.AppendChild(orders1);
                XmlElement orders2 = doc.CreateElement("OrderItem");
                item.AppendChild(orders2);
                doc.Save("a.xml");
                Console.ReadKey();
                
    
    
            }
        }
    }
    

      

  • 相关阅读:
    linux中make的用法
    Linux/Unix环境下的make命令详解
    clean 伪目标
    Redirection
    Redirect all output to file
    redirection in linux
    Advanced redirection features
    "产品测试管理&敏捷项目管理"研讨会在深圳成功举办!
    软件测试管理高级研修班(3天精品班,中国深圳 2016.1.20~22)
    2015-12-30 杨学明老师为浙江某上市企业提供《成功的产品经理》内训服务!
  • 原文地址:https://www.cnblogs.com/mengluo/p/5500755.html
Copyright © 2011-2022 走看看