XmlDocument类
XmlDocument類是.NET框架的DOC解析器。XmlDocument將XML視為樹狀結(jié)構(gòu),它裝載XML文檔,并在內(nèi)存中構(gòu)建該文檔的樹狀結(jié)構(gòu)。下面來看下XmlDocument提供了哪些功能。
一、屬性:
Attributes 獲取一個 XmlAttributeCollection,它包含該節(jié)點(diǎn)的屬性。 (繼承自 XmlNode。) BaseURI ? ? 獲取當(dāng)前節(jié)點(diǎn)的基 URI。 (重寫 XmlNode..::.BaseURI。) ChildNodes 獲取節(jié)點(diǎn)的所有子節(jié)點(diǎn)。 (繼承自 XmlNode。) DocumentElement 獲取文檔的根 XmlElement。? DocumentType 獲取包含 DOCTYPE 聲明的節(jié)點(diǎn)。? FirstChild 獲取節(jié)點(diǎn)的第一個子級。 (繼承自 XmlNode。) HasChildNodes 獲取一個值,該值指示節(jié)點(diǎn)是否有任何子節(jié)點(diǎn)。 (繼承自 XmlNode。) Implementation ? 獲取當(dāng)前文檔的 XmlImplementation 對象。? InnerText ? 獲取或設(shè)置節(jié)點(diǎn)及其所有子節(jié)點(diǎn)的串聯(lián)值。 (繼承自 XmlNode。) InnerXml 獲取或設(shè)置表示當(dāng)前節(jié)點(diǎn)子級的標(biāo)記。 (重寫 XmlNode..::.InnerXml。) IsReadOnly 獲取一個值,該值指示當(dāng)前節(jié)點(diǎn)是否是只讀的。 (重寫 XmlNode..::.IsReadOnly。) Item 已重載。? LastChild 獲取節(jié)點(diǎn)的最后一個子級。 (繼承自 XmlNode。) LocalName 獲取節(jié)點(diǎn)的本地名稱。 (重寫 XmlNode..::.LocalName。) Name 獲取節(jié)點(diǎn)的限定名。 (重寫 XmlNode..::.Name。) NamespaceURI 獲取該節(jié)點(diǎn)的命名空間 URI。 (繼承自 XmlNode。) NameTable 獲取與此實(shí)現(xiàn)關(guān)聯(lián)的 XmlNameTable。? NextSibling ? 獲取緊接在該節(jié)點(diǎn)之后的節(jié)點(diǎn)。 (繼承自 XmlNode。) NodeType 獲取當(dāng)前節(jié)點(diǎn)的類型。 (重寫 XmlNode..::.NodeType。) OuterXml ? 獲取表示此節(jié)點(diǎn)及其所有子節(jié)點(diǎn)的標(biāo)記。 (繼承自 XmlNode。) OwnerDocument 獲取當(dāng)前節(jié)點(diǎn)所屬的 XmlDocument。 (重寫 XmlNode..::.OwnerDocument。) ParentNode ? 已重載。? Prefix ? 獲取或設(shè)置該節(jié)點(diǎn)的命名空間前綴。 (繼承自 XmlNode。) PreserveWhitespace? 獲取或設(shè)置一個值,該值指示是否在元素內(nèi)容中保留空白。? PreviousSibling 獲取緊接在該節(jié)點(diǎn)之前的節(jié)點(diǎn)。 (繼承自 XmlNode。) SchemaInfo 返回節(jié)點(diǎn)的后架構(gòu)驗(yàn)證信息集 (PSVI)。 (重寫 XmlNode..::.SchemaInfo。) Schemas 獲取或設(shè)置與此 XmlDocument 關(guān)聯(lián)的 XmlSchemaSet 對象。? Value 獲取或設(shè)置節(jié)點(diǎn)的值。 (繼承自 XmlNode。) XmlResolver 設(shè)置 XmlResolver 以用于解析外部資源。
二、方法
AppendChild ? 將指定的節(jié)點(diǎn)添加到該節(jié)點(diǎn)的子節(jié)點(diǎn)列表的末尾。 (繼承自 XmlNode。) Clone ??? 創(chuàng)建此節(jié)點(diǎn)的一個副本。 (繼承自 XmlNode。) CloneNode ? 創(chuàng)建此節(jié)點(diǎn)的一個副本。 (重寫 XmlNode..::.CloneNode(Boolean)。) CreateAttribute 已重載。 創(chuàng)建具有指定名稱的 XmlAttribute。? CreateCDataSection 創(chuàng)建包含指定數(shù)據(jù)的 XmlCDataSection。? CreateComment 創(chuàng)建包含指定數(shù)據(jù)的 XmlComment。? CreateDefaultAttribute ? 創(chuàng)建具有指定前綴、本地名稱和命名空間 URI 的默認(rèn)屬性。? CreateDocumentFragment ?? 創(chuàng)建 XmlDocumentFragment。? CreateDocumentType ?? 返回新的 XmlDocumentType 對象。? CreateElement ? 已重載。 創(chuàng)建 XmlElement。? CreateEntityReference ?? 創(chuàng)建具有指定名稱的 XmlEntityReference。? CreateNavigator 已重載。 創(chuàng)建一個用于導(dǎo)航此文檔的新 XPathNavigator 對象。? CreateNode ? 已重載。 創(chuàng)建 XmlNode。? CreateProcessingInstruction 創(chuàng)建一個具有指定名稱和數(shù)據(jù)的 XmlProcessingInstruction。? CreateSignificantWhitespace 創(chuàng)建一個 XmlSignificantWhitespace 節(jié)點(diǎn)。? CreateTextNode 創(chuàng)建具有指定文本的 XmlText。? CreateWhitespace 創(chuàng)建一個 XmlWhitespace 節(jié)點(diǎn)。? CreateXmlDeclaration 創(chuàng)建一個具有指定值的 XmlDeclaration 節(jié)點(diǎn)。? GetElementById 獲取具有指定 ID 的 XmlElement。? GetElementsByTagName ? 已重載。 返回一個 XmlNodeList,它包含與指定名稱匹配的所有子代元素的列表。? GetEnumerator 提供對 XmlNode 中節(jié)點(diǎn)上“for each”樣式迭代的支持。 (繼承自 XmlNode。) GetHashCode ?? 用作特定類型的哈希函數(shù)。 (繼承自 Object。) GetNamespaceOfPrefix ? 查找當(dāng)前節(jié)點(diǎn)范圍內(nèi)離給定的前綴最近的 xmlns 聲明,并返回聲明中的命名空間 URI。 (繼承自 XmlNode。) GetPrefixOfNamespace ? 查找當(dāng)前節(jié)點(diǎn)范圍內(nèi)離給定的命名空間 URI 最近的 xmlns 聲明,并返回聲明中定義的前綴。 (繼承自 XmlNode。) ImportNode 將節(jié)點(diǎn)從另一個文檔導(dǎo)入到當(dāng)前文檔。? InsertAfter ? 將指定的節(jié)點(diǎn)緊接著插入指定的引用節(jié)點(diǎn)之后。 (繼承自 XmlNode。) InsertBefore 將指定的節(jié)點(diǎn)緊接著插入指定的引用節(jié)點(diǎn)之前。 (繼承自 XmlNode。) Load ? 已重載。 從 Stream、URL、TextReader 或 XmlReader 加載指定的 XML 數(shù)據(jù)。? LoadXml ? 從指定的字符串加載 XML 文檔。? Normalize 將此 XmlNode 下子樹完全深度中的所有 XmlText 節(jié)點(diǎn)都轉(zhuǎn)換成“正常”形式,在這種形式中只有標(biāo)記(即標(biāo)記、注釋、處理指令、 CDATA 節(jié)和實(shí)體引用)分隔 XmlText 節(jié)點(diǎn),也就是說,沒有相鄰的 XmlText 節(jié)點(diǎn)。 (繼承自 XmlNode。) PrependChild 將指定的節(jié)點(diǎn)添加到該節(jié)點(diǎn)的子節(jié)點(diǎn)列表的開頭。 (繼承自 XmlNode。) ReadNode ? 根據(jù) XmlReader 中的信息創(chuàng)建一個 XmlNode 對象。讀取器必須定位在節(jié)點(diǎn)或?qū)傩陨稀? RemoveAll ? 移除當(dāng)前節(jié)點(diǎn)的所有子節(jié)點(diǎn)和/或?qū)傩浴?(繼承自 XmlNode。) RemoveChild 移除指定的子節(jié)點(diǎn)。 (繼承自 XmlNode。) ReplaceChild 用 newChild 節(jié)點(diǎn)替換子節(jié)點(diǎn) oldChild。 (繼承自 XmlNode。) Save 已重載。 將 XML 文檔保存到指定的位置。? SelectNodes ? 已重載。? SelectSingleNode 已重載。? Supports 測試 DOM 實(shí)現(xiàn)是否實(shí)現(xiàn)特定的功能。 (繼承自 XmlNode。) Validate 已重載。 驗(yàn)證 XmlDocument 是不是 Schemas 屬性中包含的 XML 架構(gòu)定義語言 (XSD) 架構(gòu)。? WriteContentTo 將 XmlDocument 節(jié)點(diǎn)的所有子級保存到指定的 XmlWriter 中。 (重寫 XmlNode..::.WriteContentTo(XmlWriter)。) WriteTo 將 XmlDocument 節(jié)點(diǎn)保存到指定的 XmlWriter。 (重寫 XmlNode..::.WriteTo(XmlWriter)。)
三、事件
NodeChanged 當(dāng)屬于該文檔的節(jié)點(diǎn)的 Value 已被更改時發(fā)生。 NodeChanging 當(dāng)屬于該文檔的節(jié)點(diǎn)的 Value 將被更改時發(fā)生。? NodeInserted ? 當(dāng)屬于該文檔的節(jié)點(diǎn)已被插入另一個節(jié)點(diǎn)時發(fā)生。? NodeInserting 當(dāng)屬于該文檔的節(jié)點(diǎn)將被插入另一個節(jié)點(diǎn)時發(fā)生。? NodeRemoved 當(dāng)屬于該文檔的節(jié)點(diǎn)已被從其父級移除時發(fā)生。? NodeRemoving 當(dāng)屬于該文檔的節(jié)點(diǎn)將被從文檔中移除時發(fā)生。
助記屬性:
PreviousSibling 上一個兄弟節(jié)點(diǎn) NextSibling 下一個兄弟節(jié)點(diǎn) FirstChild 第一個子節(jié)點(diǎn) LastChild 最后一個子節(jié)點(diǎn) ChildNodes 子節(jié)點(diǎn)集合 ParentNode ? 父節(jié)點(diǎn)
代碼示例:
xml文檔:
<?xml version="1.0" encoding="utf-8" ?> <Article> <author age="30">張三</author> <length>12000</length> <price>42</price> </Article>代碼:
static void Main(string[] args){XmlDocument doc = new XmlDocument(); doc.Load(@"C:\Users\Administrator\Desktop\ConsoleApplication1\ConsoleApplication1\Test.xml"); //先獲取一個唯一的Article節(jié)點(diǎn),再獲取其下的第一個子節(jié)點(diǎn) 然后再獲取該節(jié)點(diǎn)下的屬性集合 XmlAttributeCollection xc = doc.SelectSingleNode("Article").FirstChild.Attributes; string age = xc[0].Value; //不過是一個定制的集合罷了,還是集合那套東西 //string age = xc["age"].Value; 支持兩種索引訪問 Console.WriteLine(age); //輸出30 string baseuri = doc.SelectSingleNode("Article").FirstChild.BaseURI; Console.WriteLine(baseuri); //輸出 file:///C:\Users\Administrator\Desktop\ConsoleApplication1\ConsoleApplication1\Test.xml XmlNodeList listNode = doc.SelectSingleNode("Article").ChildNodes; //獲取Article節(jié)點(diǎn)下的所有節(jié)點(diǎn)列表 for (int i = 0; i < listNode.Count;i++ ) //XmlNodeList不支持foreach遍歷,只能用for { Console.Write(listNode[i].Name + " : " + listNode[i].InnerText); //輸出 author:張三 length:12000 price:30 Name獲取的是限定名,也就是標(biāo)記名稱 } XmlElement xe = doc.DocumentElement; //獲取根節(jié)點(diǎn) Console.WriteLine(xe.Name); //輸出 Article //XmlDocumentType xdt = doc.DocumentType; //獲取包含 DOCTYPE 聲明的節(jié)點(diǎn)。應(yīng)該是由DTD限定的節(jié)點(diǎn)。 //Console.Write(xdt.Name); //此處報 未將對象引用設(shè)置到對象的實(shí)例,因?yàn)檎也坏接蠨OCTYPE聲明的元素 Console.WriteLine(doc.HasChildNodes); //輸出 True 當(dāng)前Document是否包含子節(jié)點(diǎn)。 //XmlImplementation xi = doc.Implementation; //不懂怎么用 //xi.ToString(); Console.WriteLine(doc.InnerText); //獲取當(dāng)前文檔的內(nèi)容 輸出 張三 12000 30 Console.WriteLine(doc.InnerXml); //輸出 整個Xml文件的字符串內(nèi)容 Console.WriteLine(doc.IsReadOnly); //獲取當(dāng)前文檔是否是只讀的。輸出 False XmlNode node = doc.LastChild; Console.WriteLine(node.InnerText); //輸出 張三 12000 30 因?yàn)樽詈笠粋€節(jié)點(diǎn)是Article節(jié)點(diǎn),輸出Article節(jié)點(diǎn)的所有內(nèi)容 Console.WriteLine(doc.LocalName); //輸出 #document Console.WriteLine(doc.SelectSingleNode("Article").Name); //輸出Article Console.WriteLine(doc.SelectSingleNode("Article").FirstChild.NextSibling.Name); //length author的下一個兄弟節(jié)點(diǎn) 是length XmlNodeType xnt = doc.SelectSingleNode("Article").NodeType; Console.WriteLine(xnt); //輸出Element,表明該節(jié)點(diǎn)是元素節(jié)點(diǎn) string str = doc.SelectSingleNode("Article").OuterXml; //此節(jié)點(diǎn)及其所有自己點(diǎn)標(biāo)記,輸出Article節(jié)點(diǎn)的所有內(nèi)容 <Article>省略...</Article> Console.WriteLine(str); XmlDocument x = new XmlDocument(); x.LoadXml(str); Console.WriteLine(doc.SelectSingleNode("Article").OwnerDocument); //獲取該節(jié)點(diǎn)所屬的XmlDocument XmlNode xn = doc.SelectSingleNode("Article").LastChild.ParentNode; //ParentNode獲取直接父節(jié)點(diǎn)。 Console.WriteLine(xn.Name); //輸出 Article Console.WriteLine(doc.PreserveWhitespace); //是否保留空白 輸出False XmlNode xn1 = doc.SelectSingleNode("Article").LastChild.PreviousSibling; Console.WriteLine(xn1.Name); //輸出length 的確是最后一個節(jié)點(diǎn)的前一個節(jié)點(diǎn)。 Console.ReadKey(); }為了更加好的展示一些屬性,現(xiàn)在將xml換成這樣:
<?xml version="1.0" encoding="utf-8" ?> <h:Article xmlns:h = "http://www.xxx.com/"> <!--默認(rèn)命名空間--> <h:author age="30">張三</h:author> <h:length>12000</h:length> <h:price>42</h:price> </h:Article>代碼如下:
static void Main(string[] args){XmlDocument doc = new XmlDocument(); doc.Load(@"C:\Users\Administrator\Desktop\ConsoleApplication1\ConsoleApplication1\Test.xml"); XmlNamespaceManager xnm = new XmlNamespaceManager(doc.NameTable); xnm.AddNamespace("h", "http://www.xxx.com/"); XmlNode Article = doc.SelectSingleNode("h:Article", xnm); string namespace1 = Article.InnerText; Console.WriteLine(namespace1); //輸出 張三 12000 30 Console.WriteLine(Article.Prefix); //輸出 h 獲取當(dāng)前節(jié)點(diǎn)的前綴 Console.WriteLine(Article.NamespaceURI); //輸出 http://www.xxx.com/123 獲取當(dāng)前節(jié)點(diǎn)所在的命名空間 Console.WriteLine(Article.FirstChild.Name + "---" + Article.FirstChild.Value + "---" + Article.FirstChild.LocalName); //以上一行代碼輸出 h:author------author //SchemaInfo 返回節(jié)點(diǎn)的后架構(gòu)驗(yàn)證信息集 (PSVI)。//Value 獲取或設(shè)置節(jié)點(diǎn)的值。 (繼承自 XmlNode。) //XmlResolver 設(shè)置 XmlResolver 以用于解析外部資源。 Console.ReadKey(); }再來一個展示一下Schemas這個常用的屬性
static void Main(string[] args){XmlDocument doc = new XmlDocument(); //創(chuàng)建文檔 doc.Schemas.Add(null, @"C:\Users\Administrator\Desktop\ConsoleApplication1\ConsoleApplication1\person.xsd"); //添加一個架構(gòu)對象到本XmlDocument doc.Load(@"C:\Users\Administrator\Desktop\ConsoleApplication1\ConsoleApplication1\person.xml"); //加載xml文件 Console.WriteLine(doc.Schemas.Count); //輸出1 就是第二行添加的那個 Console.WriteLine(doc.SchemaInfo.MemberType); //XmlResolver 設(shè)置 XmlResolver 以用于解析外部資源。 Console.ReadKey(); }下面來試下XmlDocument的方法
Test.xml的代碼如下: <?xml version="1.0" encoding="utf-8" ?> <bookstore> <book> <id>1</id> <title lang="屬性1">三國演義</title> <author>羅貫中</author> <year>2005</year> <price id='a1"'>38.5</price> </book> <book> <id>2</id> <title lang="屬性2">西游記</title> <author>吳承恩</author> <year>2004</year> <price>37.5</price> </book> </bookstore>主程序代碼如下:
static void Main(string[] args){XmlDocument doc = new XmlDocument(); //創(chuàng)建文檔 doc.Load(@"C:\Users\Administrator\Desktop\ConsoleApplication1\ConsoleApplication1\Test.xml"); //加載xml文件 XmlNode node1 = doc.CreateNode(XmlNodeType.Element, "pagecount", null); node1.InnerText = "222"; doc.SelectSingleNode("/bookstore").AppendChild(node1); //執(zhí)行之后 <pagecount>222</pagecount>元素被添加到</bookstore>前面 doc.Save(@"D:\123.xml"); XmlNode node2 = doc.SelectSingleNode("/bookstore/book[1]/title[1]").Clone(); //克隆一個節(jié)點(diǎn)出來 Console.WriteLine(node2.InnerText); //輸出三國演義 XmlNode node3 = doc.SelectSingleNode("/bookstore/book[1]/title[1]").CloneNode(true); //參數(shù)決定是否克隆子節(jié)點(diǎn)數(shù)(如果false,文本節(jié)點(diǎn)也不克隆) Console.WriteLine(node3.InnerText); //輸出三國演義 XmlAttribute attr = doc.CreateAttribute("age"); //創(chuàng)建一個age屬性 attr.Value = "23"; doc.SelectSingleNode("/bookstore/book[1]/author[1]").Attributes.Append(attr); //執(zhí)行之后第一個作者變?yōu)?<author age="23">羅貫中</author> doc.Save(@"D:\123.xml"); XmlCDataSection cdata = doc.CreateCDataSection("我&你"); doc.SelectSingleNode("/bookstore/book[1]/author[1]").AppendChild(cdata); //執(zhí)行之后author變?yōu)?lt;author age="23">羅貫中<![CDATA[我&你]]></author> doc.Save(@"D:\123.xml"); XmlComment com = doc.CreateComment("2013-2-27 22:37:25"); doc.SelectSingleNode("/bookstore/book[1]/title[1]").AppendChild(com); //執(zhí)行之后title變?yōu)?lt;title lang="屬性1">三國演義<!--2013-2-27 22:37:25--></title> doc.Save(@"D:\123.xml"); XmlDocument doc1 = new XmlDocument(); XmlDocumentFragment xdf = doc1.CreateDocumentFragment(); //一個xml片段,這個類敢情好用 xdf.InnerXml = "<item>widget</item>"; doc1.AppendChild(xdf); Console.WriteLine(doc1.OuterXml); //輸出<item>widget</item> //CreateDefaultAttribute 創(chuàng)建具有指定前綴、本地名稱和命名空間 URI 的默認(rèn)屬性。 //CreateDocumentType 返回新的 XmlDocumentType 對象。 XmlDocument doc2 = new XmlDocument(); XmlElement element = doc2.CreateElement("title"); //創(chuàng)建一個title 如果現(xiàn)在保存是輸出<title/> 因?yàn)檫€沒有內(nèi)容 doc2.AppendChild(element); XmlEntityReference xer = doc2.CreateEntityReference("h"); doc2.LastChild.AppendChild(xer); Console.WriteLine(doc2.OuterXml); //輸出</title>&h;</title> XPathNavigator nav = doc2.CreateNavigator(); //一個通過光標(biāo)的導(dǎo)航模型遍歷XML文檔的數(shù)據(jù) XmlText text = doc2.CreateTextNode("你好啊"); //創(chuàng)建一個文本節(jié)點(diǎn) doc2.SelectSingleNode("/title").AppendChild(text); Console.WriteLine(doc2.OuterXml); //輸出</title>&h;你好啊</title> XmlWhitespace xws = doc2.CreateWhitespace(" "); //創(chuàng)建一個空白節(jié)點(diǎn) doc2.SelectSingleNode("/title").AppendChild(xws); Console.WriteLine(doc2.OuterXml); //輸出</title>&h;你好啊 </title> XmlDeclaration xd = doc2.CreateXmlDeclaration("1.0", "utf-8", "yes"); //xml頭 XML聲明部分 XmlNode root = doc2.SelectSingleNode("/title"); doc2.InsertBefore(xd, root); Console.WriteLine(doc2.OuterXml); //執(zhí)行之后 在頭部加入了<?xml version="1.0" encoding="utf-8" standalont="yes"?> XmlSignificantWhitespace xsw = doc2.CreateSignificantWhitespace(" "); XmlElement ele = doc2.CreateElement("white"); ele.InnerText = "空白啊空白"; ele.AppendChild(xsw); doc2.SelectSingleNode("/title").AppendChild(ele); Console.WriteLine(doc2.OuterXml); //還是添加一大堆空白,不知道與CreateWhitespace有什么區(qū)別 XmlDocument doc3 = new XmlDocument(); String PItext = "type='text/xsl' href='book.xsl'"; XmlProcessingInstruction newPI = doc3.CreateProcessingInstruction("xml-stylesheet", PItext); doc3.AppendChild(newPI); Console.WriteLine(doc3.OuterXml); //輸出 <?xml-stylesheet type="text/xsl" hred="book.xsl"?> //GetElementById 獲取具有指定 ID 的 XmlElement。 //GetElementsByTagName 已重載。 返回一個 XmlNodeList,它包含與指定名稱匹配的所有子代元素的列表。 //GetEnumerator 提供對 XmlNode 中節(jié)點(diǎn)上“for each”樣式迭代的支持。 (繼承自 XmlNode。) //GetNamespaceOfPrefix 查找當(dāng)前節(jié)點(diǎn)范圍內(nèi)離給定的前綴最近的 xmlns 聲明,并返回聲明中的命名空間 URI。 (繼承自 XmlNode。) //GetPrefixOfNamespace 查找當(dāng)前節(jié)點(diǎn)范圍內(nèi)離給定的命名空間 URI 最近的 xmlns 聲明,并返回聲明中定義的前綴。 (繼承自 XmlNode。) //ImportNode 將節(jié)點(diǎn)從另一個文檔導(dǎo)入到當(dāng)前文檔。 //InsertAfter 將指定的節(jié)點(diǎn)緊接著插入指定的引用節(jié)點(diǎn)之后。 (繼承自 XmlNode。) //InsertBefore 將指定的節(jié)點(diǎn)緊接著插入指定的引用節(jié)點(diǎn)之前。 (繼承自 XmlNode。) //LoadXml 從指定的字符串加載 XML 文檔。 //Normalize 將此 XmlNode 下子樹完全深度中的所有 XmlText 節(jié)點(diǎn)都轉(zhuǎn)換成“正常”形式,在這種形式中只有標(biāo)記(即標(biāo)記、注釋、處理指令、 CDATA 節(jié)和實(shí)體引用)分隔 XmlText 節(jié)點(diǎn),也就是說,沒有相鄰的 XmlText 節(jié)點(diǎn)。 (繼承自 XmlNode。) //PrependChild 將指定的節(jié)點(diǎn)添加到該節(jié)點(diǎn)的子節(jié)點(diǎn)列表的開頭。 (繼承自 XmlNode。) //ReadNode 根據(jù) XmlReader 中的信息創(chuàng)建一個 XmlNode 對象。讀取器必須定位在節(jié)點(diǎn)或?qū)傩陨稀?//RemoveAll 移除當(dāng)前節(jié)點(diǎn)的所有子節(jié)點(diǎn)和/或?qū)傩浴?(繼承自 XmlNode。) //RemoveChild 移除指定的子節(jié)點(diǎn)。 (繼承自 XmlNode。) //ReplaceChild 用 newChild 節(jié)點(diǎn)替換子節(jié)點(diǎn) oldChild。 (繼承自 XmlNode。) //Supports 測試 DOM 實(shí)現(xiàn)是否實(shí)現(xiàn)特定的功能。 (繼承自 XmlNode。) //Validate 已重載。 驗(yàn)證 XmlDocument 是不是 Schemas 屬性中包含的 XML 架構(gòu)定義語言 (XSD) 架構(gòu)。 //WriteContentTo 將 XmlDocument 節(jié)點(diǎn)的所有子級保存到指定的 XmlWriter 中。 (重寫 XmlNode..::.WriteContentTo(XmlWriter)。) //WriteTo 將 XmlDocument 節(jié)點(diǎn)保存到指定的 XmlWriter。 (重寫 XmlNode..::.WriteTo(XmlWriter)。) Console.ReadKey(); }轉(zhuǎn)載于:https://www.cnblogs.com/1175429393wljblog/p/4441150.html
總結(jié)
以上是生活随笔為你收集整理的XmlDocument类的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 网络电话
- 下一篇: Schlumberger.SPAN.Ro