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

//創(chuàng)建根節(jié)點(diǎn) System.Xml.XmlNode root = doc.CreateNode(System.Xml.XmlNodeType " /> 啪啪综合网,麻豆xxxxhd videos,sss欧美华人整片在线观看

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

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

C#: 

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

//創(chuàng)建根節(jié)點(diǎn) 
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); 

//為節(jié)點(diǎn)添加屬性 
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); 

//為節(jié)點(diǎn)增加值 
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 = "歡迎光臨【孟憲會(huì)之精彩世界】"; 

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

//添加節(jié)點(diǎn)聲明 
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); 

//查詢節(jié)點(diǎn) 
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 = "歡迎光臨【孟憲會(huì)之精彩世界】:http://dotNET.ASPx.cc/"; 

//創(chuàng)建CDATA節(jié)點(diǎn) 
System.Xml.XmlCDataSection xcds = doc.CreateCDataSection("<a href='http://dotNET.ASPx.cc/'>【孟憲會(huì)之精彩世界】</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

'創(chuàng)建根節(jié)點(diǎn) 
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)

'為節(jié)點(diǎn)添加屬性 
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)

'為節(jié)點(diǎn)增加值 
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 = "歡迎光臨【孟憲會(huì)之精彩世界】"

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

'添加節(jié)點(diǎn)聲明 
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)

'查詢節(jié)點(diǎn) 
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 = "歡迎光臨【孟憲會(huì)之精彩世界】:http://dotNET.ASPx.cc/"

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

Response.Write(xcds.InnerText)

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

AspNet技術(shù)asp.net下創(chuàng)建、查詢、修改帶名稱空間的 XML 文件的例子,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 野战露脸在线视频国产 | 亚洲欧美手机在线观看 | 91在线视频在线观看 | 视色4se网站在线 | 国产成人精品一区二区三区 | 亚洲不卡一区二区三区在线 | 男女一区二区三区免费 | 欧美成人全部费免网站 | 中文字幕在线观看2023 | 国产自制一区 | 五月婷婷俺来也 | 精品一区二区三区在线视频 | 久久国产精品夜色 | 麻豆精品成人免费国产片 | 欧美一欧美一区二三区性 | 欧美日韩亚洲国产精品一区二区 | 视频一区二区在线观看 | www.射射射 | 六月丁香深爱六月综合激情 | 欧美巨大另类极品videohd | 欧美91精品久久久久网免费 | 欧美成人全部免费观看1314色 | 美女网站色免费 | 伊人色在线观看 | 牛牛影视精品一区二区在线看 | 米奇777四色精品人人爽 | 伊人网站在线 | 精品亚洲成a人在线观看 | 日本精品视频一区二区三区 | 久久婷婷久久一区二区三区 | 伊人网综合在线视频 | 国产大片好看免费播放 | 日本一道一区二区免费看 | 国产福利小视频在线播放观看 | 黄色片在线观看网站 | 韩国三级日本三级美三级 | 久久久久久尹人网香蕉 | 美女图片在线视频精品播放 | 调教大奶| 亚洲手机国产精品 | 国产高清美女一级a毛片 |