string w3NameSpace = "http://www.w3.org/2000/xmlns/"; System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

//創建根節點 System.Xml.XmlNode root = doc.CreateNode(System.Xml.XmlNodeType " /> 国内黄色片,亚欧乱亚欧乱色视频免费,羞羞视频在线免费

一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

asp.net下創建、查詢、修改帶名稱空間的 XML 文件的例子

C#: 

string w3NameSpace = "http://www.w3.org/2000/xmlns/"; 
System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); 

//創建根節點 
System.Xml.XmlNode root = doc.CreateNode(System.Xml.XmlNodeType.Element, "w", "wordDocument", "http://schemas.microsoft.com/office/word/2003/2/wordml"); 
System.Xml.XmlAttribute xa; 
xa = doc.CreateAttribute("xmlns", "v", w3NameSpace); 
xa.Value = "urn:schemas-microsoft-com:vml"; 
root.Attributes.Append(xa); 

//為節點添加屬性 
xa = doc.CreateAttribute("xmlns", "w10", w3NameSpace); 
xa.Value = "urn:schemas-microsoft-com:office:word"; 
root.Attributes.Append(xa); 

xa = doc.CreateAttribute("xmlns", "SL", w3NameSpace); 
xa.Value = "http://schemas.microsoft.com/schemaLibrary/2003/2/core"; 
root.Attributes.Append(xa); 

xa = doc.CreateAttribute("xmlns", "aml", w3NameSpace); 
xa.Value = "http://schemas.microsoft.com/aml/2001/core"; 
root.Attributes.Append(xa); 

xa = doc.CreateAttribute("xmlns", "wx", w3NameSpace); 
xa.Value = "http://schemas.microsoft.com/office/word/2003/2/auxHint"; 
root.Attributes.Append(xa); 

xa = doc.CreateAttribute("xmlns", "o", w3NameSpace); 
xa.Value = "urn:schemas-microsoft-com:office:office"; 
root.Attributes.Append(xa); 

xa = doc.CreateAttribute("xmlns", "dt", w3NameSpace); 
xa.Value = "uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"; 
root.Attributes.Append(xa); 

xa = doc.CreateAttribute("xmlns", "space", w3NameSpace); 
xa.Value = "preserve"; 
root.Attributes.Append(xa); 

//為節點增加值 
System.Xml.XmlNode body = doc.CreateNode(System.Xml.XmlNodeType.Element, "v", "body", "urn:schemas-microsoft-com:vml"); 
System.Xml.XmlNode childNode = doc.CreateNode(System.Xml.XmlNodeType.Element, "o", "t", "urn:schemas-microsoft-com:office:office"); 
childNode.InnerText = "歡迎光臨【孟憲會之精彩世界】"; 

//添加到內存樹中 
body.AppendChild(childNode); 
root.AppendChild(body); 
doc.AppendChild(root); 

//添加節點聲明 
System.Xml.XmlDeclaration xd = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); 
doc.InsertBefore(xd, doc.DocumentElement); 

//添加處理指令 
System.Xml.XmlProcessingInstruction spi = doc.CreateProcessingInstruction("mso-application", "progid=/"Word.Document/""); 
doc.InsertBefore(spi, doc.DocumentElement); 

//查詢節點 
System.Xml.XmlNamespaceManager nsmanager = new System.Xml.XmlNamespaceManager(doc.NameTable); 
nsmanager.AddNamespace("w", "http://schemas.microsoft.com/office/word/2003/2/wordml"); 
nsmanager.AddNamespace("v", "urn:schemas-microsoft-com:vml"); 
nsmanager.AddNamespace("o", "urn:schemas-microsoft-com:office:office"); 
System.Xml.XmlNode node = doc.SelectSingleNode("w:wordDocument/v:body/o:t", nsmanager); 
Response.Write(node.InnerText); 

node.InnerText = "歡迎光臨【孟憲會之精彩世界】:http://dotNET.ASPx.cc/"; 

//創建CDATA節點 
System.Xml.XmlCDataSection xcds = doc.CreateCDataSection("<a href='http://dotNET.ASPx.cc/'>【孟憲會之精彩世界】</a>"); 
node.ParentNode.InsertAfter(xcds, node); 

Response.Write(xcds.InnerText); 

doc.Save(Server.MapPath("test.xml")); 

VB.NET

Dim w3NameSpace As String = "http://www.w3.org/2000/xmlns/"
Dim doc As New System.Xml.XmlDocument

'創建根節點 
Dim root As System.Xml.XmlNode = doc.CreateNode(System.Xml.XmlNodeType.Element, "w", "wordDocument", "http://schemas.microsoft.com/office/word/2003/2/wordml")
Dim xa As System.Xml.XmlAttribute
xa = doc.CreateAttribute("xmlns", "v", w3NameSpace)
xa.Value = "urn:schemas-microsoft-com:vml"
root.Attributes.Append(xa)

'為節點添加屬性 
xa = doc.CreateAttribute("xmlns", "w10", w3NameSpace)
xa.Value = "urn:schemas-microsoft-com:office:word"
root.Attributes.Append(xa)

xa = doc.CreateAttribute("xmlns", "SL", w3NameSpace)
xa.Value = "http://schemas.microsoft.com/schemaLibrary/2003/2/core"
root.Attributes.Append(xa)

xa = doc.CreateAttribute("xmlns", "aml", w3NameSpace)
xa.Value = "http://schemas.microsoft.com/aml/2001/core"
root.Attributes.Append(xa)

xa = doc.CreateAttribute("xmlns", "wx", w3NameSpace)
xa.Value = "http://schemas.microsoft.com/office/word/2003/2/auxHint"
root.Attributes.Append(xa)

xa = doc.CreateAttribute("xmlns", "o", w3NameSpace)
xa.Value = "urn:schemas-microsoft-com:office:office"
root.Attributes.Append(xa)

xa = doc.CreateAttribute("xmlns", "dt", w3NameSpace)
xa.Value = "uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
root.Attributes.Append(xa)

xa = doc.CreateAttribute("xmlns", "space", w3NameSpace)
xa.Value = "preserve"
root.Attributes.Append(xa)

'為節點增加值 
Dim body As System.Xml.XmlNode = doc.CreateNode(System.Xml.XmlNodeType.Element, "v", "body", "urn:schemas-microsoft-com:vml")
Dim childNode As System.Xml.XmlNode = doc.CreateNode(System.Xml.XmlNodeType.Element, "o", "t", "urn:schemas-microsoft-com:office:office")
childNode.InnerText = "歡迎光臨【孟憲會之精彩世界】"

'添加到內存樹中 
body.AppendChild(childNode)
root.AppendChild(body)
doc.AppendChild(root)

'添加節點聲明 
Dim xd As System.Xml.XmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes")
doc.InsertBefore(xd, doc.DocumentElement)

'添加處理指令 
Dim spi As System.Xml.XmlProcessingInstruction = doc.CreateProcessingInstruction("mso-application", "progid=""Word.Document""")
doc.InsertBefore(spi, doc.DocumentElement)

'查詢節點 
Dim nsmanager As New System.Xml.XmlNamespaceManager(doc.NameTable)
nsmanager.AddNamespace("w", "http://schemas.microsoft.com/office/word/2003/2/wordml")
nsmanager.AddNamespace("v", "urn:schemas-microsoft-com:vml")
nsmanager.AddNamespace("o", "urn:schemas-microsoft-com:office:office")
Dim node As System.Xml.XmlNode = doc.SelectSingleNode("w:wordDocument/v:body/o:t", nsmanager)
Response.Write(node.InnerText)

node.InnerText = "歡迎光臨【孟憲會之精彩世界】:http://dotNET.ASPx.cc/"

'創建CDATA節點 
Dim xcds As System.Xml.XmlCDataSection = doc.CreateCDataSection("<a href='http://dotNET.ASPx.cc/'>【孟憲會之精彩世界】</a>")
node.ParentNode.InsertAfter(xcds, node)

Response.Write(xcds.InnerText)

doc.Save(Server.MapPath("test.xml")) 

AspNet技術asp.net下創建、查詢、修改帶名稱空間的 XML 文件的例子,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 亚洲丝袜一区二区 | 2021国产精品自产拍在线 | 综合 91在线精品 | 交资源网在线观看 | 亚洲福利在线观看 | 91热久久免费频精品99欧美 | 久久精品国产乱子伦多人 | 亚洲天堂五月天 | 五月婷色 | 91网页| 亚洲国产99在线精品一区二区 | 好属妞这里只有精品久久 | 97久久曰曰久久久 | 国产日韩精品欧美在线ccc | 在线观看精品视频网站www | 大量出精汇编免费看 | 婷婷影院在线综合免费视频 | 一本色道 | 亚洲黄色在线观看视频 | 欧美激情在线看 | 国产一区二区成人 | 性满足久久久久久久久 | 一本一道久久综合狠狠老 | 亚洲第一成年网 | 婷婷三级 | 一二三区在线观看 | 韩国理伦一级毛片 | adc影院在线观看成人 | 91免费在线视频观看 | 波多野结衣在线影院 | 女人天堂网 | 成人特黄午夜性a一级毛片 成人婷婷 | 99精品视频在线观看免费 | 亚洲小说欧美激情另类 | 午夜国产精品视频 | 综合色88| 欧洲一卡2卡三卡4卡免费观看 | 美女三级视频 | 国产婷婷综合在线视频中 | 久久只这里是精品66 | 国产精品中文 |