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();
                
    
    
            }
        }
    }
    

      

  • 相关阅读:
    spring core源码解读之ASM4用户手册翻译之一asm简介
    nginx启动,重启,关闭命令
    linux LVM分区查看dm设备
    jdbc 对sqlite的基本操作
    linux配置多个ip
    细说Linux下的虚拟主机那些事儿
    打造字符界面的多媒体Linux系统
    linux计划crontab
    因修改/etc/ssh权限导致的ssh不能连接异常解决方法
    Linux修改主机名
  • 原文地址:https://www.cnblogs.com/mengluo/p/5500755.html
Copyright © 2011-2022 走看看