• XML


    XML基础

    namespace XMLElement和XMLNode
    {
        class Program
        {
            static void Main(string[] args)
            {
                XmlDocument doc = new XmlDocument();
                XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "GB2312", null);
                doc.AppendChild(dec);
                #region ok
                //创建一个根节点(一级)
                //XmlElement root = doc.CreateElement("First");
                //doc.AppendChild(root);
                ////创建节点(二级)
                //XmlNode node = doc.CreateElement("Seconde");
                ////创建节点(三级)
                //XmlElement element1 = doc.CreateElement("Third1");
                //element1.SetAttribute("Name", "Sam");
                //element1.SetAttribute("ID", "665");
                //element1.InnerText = "Sam Comment";
                //node.AppendChild(element1);
    
                //XmlElement element2 = doc.CreateElement("Third2");
                //element2.SetAttribute("Name", "Round");
                //element2.SetAttribute("ID", "678");
                //element2.InnerText = "Round Comment";
                //node.AppendChild(element2);
                // root.AppendChild(node); 
                #endregion
    
                #region ojbk2
                //XmlElement root = doc.CreateElement("siiscmd");
                ////root.SetAttribute("xmlns", "zkb");//如果不给Element加Attribute就会是一个闭合的;否则就是:<siiscmd xmlns="zkb" />
                ////还有就是说:如果实力了一个XmlElement或XmlNode,如果不给它里面填充节点,结果就是:单闭合的: <small />
                ////如果填充了节点:就是双闭合的状态
                ////
                //XmlNode issueinv = doc.CreateElement("issueinv");
                //XmlElement roots = doc.CreateElement("small");
                //issueinv.AppendChild(roots);
                //root.AppendChild(issueinv);
                //doc.AppendChild(root); 
                #endregion
    
    
                #region 0jbk3
                //DateTime now = DateTime.Now;
                ////XmlDocument doc = new XmlDocument();
                //////生成发票xml()
                ////XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "GB2312", null);
                ////doc.AppendChild(dec);
                ////一语惊醒梦中你
                ////从下面打印出来的节点看,差不多可以得出
                ////XmlElement用于:<name>Prozkb</name>
                ////XmlNode则用于
                ////<invkind> <--左边的这个是XMLNode
                ////  <value>invkind</value> <--左边的这个是XMLElement
                ////</invkind>
                //XmlElement root = doc.CreateElement("siiscmd");
                //root.SetAttribute("xmlns", "AppSettings['xmlns']");
                //doc.AppendChild(root);
    
                //XmlNode issueinv = doc.CreateElement("issueinv");
                //root.AppendChild(issueinv);
    
                //XmlNode invrecord = doc.CreateElement("invrecord");
                //issueinv.AppendChild(invrecord);
    
    
                //XmlNode invrecordhead = doc.CreateElement("invrecordhead");
                //invrecord.AppendChild(invrecordhead);
    
                //XmlElement machinetaxnr = doc.CreateElement("machinetaxnr");
                //machinetaxnr.InnerText = "AppSettings['machinetaxnr']";
                //invrecordhead.AppendChild(machinetaxnr);
    
                //XmlElement machinenr = doc.CreateElement("machinenr");
                //machinenr.InnerText = "machinenr";
                //invrecordhead.AppendChild(machinenr);
    
                //XmlNode invkind = doc.CreateElement("invkind");
                //XmlElement value = doc.CreateElement("value");
                //value.InnerText = "invkind";
                //invkind.AppendChild(value);
                //invrecordhead.AppendChild(invkind);
    
                //XmlNode doctype = doc.CreateElement("doctype");
                //value = doc.CreateElement("value");
                //value.InnerText = "doctype";
                //doctype.AppendChild(value);
                //invrecordhead.AppendChild(doctype);
    
                //XmlElement docnr = doc.CreateElement("docnr");
                //docnr.InnerText = "original_number";
                //invrecordhead.AppendChild(docnr);
    
                //XmlElement docdate = doc.CreateElement("docdate");
                //docdate.InnerText = now.ToString("yyyy-MM-dd HH:mm:ss");
                //invrecordhead.AppendChild(docdate);
    
                //XmlElement custnr = doc.CreateElement("custnr");
                //invrecordhead.AppendChild(custnr); 
                #endregion
                doc.Save(@"d:xxxxxX.xml");
             
    
               
            }
        }
    }
  • 相关阅读:
    python print format
    ElasticSearch的lowlevelApi和低级别API
    Ubuntu下搜狗输入法突然无法输入中文
    mysql基本操作
    eclipse配置代码自动提示
    使用JAAS登录kerberos服务器
    centos7配置kerberos服务,并使用JAAS登录
    LDAP none、simple、strong 笔记
    linux下yum安装最新稳定版nginx
    Mybatis if标签判断大小
  • 原文地址:https://www.cnblogs.com/ZkbFighting/p/8889608.html
Copyright © 2020-2023  润新知