C#——LINQ to XML(创建 XML 树)
using System.Xml.Linq; static void Main(string[] args) { XElement contacts = new XElement("Contacts", new XElement("Contact", new XElement("Name", "Patrick Hines"), new XElement("Phone", "206-555-0144", new XAttribute("Type", "Home")), new XElement("phone", "425-555-0145", new XAttribute("Type", "Work")), new XElement("Address", new XElement("Street1", "123 Main St"), new XElement("City", "Mercer Island"), new XElement("State", "WA"), new XElement("Postal", "68042") ) ) ); contacts.Save("Contacts.xml"); }
<?xml version="1.0" encoding="utf-8"?> <Contacts> <Contact> <Name>Patrick Hines</Name> <Phone Type="Home">206-555-0144</Phone> <phone Type="Work">425-555-0145</phone> <Address> <Street1>123 Main St</Street1> <City>Mercer Island</City> <State>WA</State> <Postal>68042</Postal> </Address> </Contact> </Contacts>
------------------------------------
承接
**视觉检测软件开发及调试
**工业软件开发
**上位机软件开发
wechat:luoran2024
qq:565934058
email:taoyuansu@qq.com
海量教育资源及影视资源下载
微信公众号:EFun科技
------------------------------------
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号