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)系我們修改或刪除,多謝。

主站蜘蛛池模板: 亚洲图片校园另激情类小说 | 欧美一级久久久久久久大片 | 在线成人免费视频 | 欧美又黄又嫩大片a级 | 国产人成精品综合欧美成人 | 国产手机在线播放 | 精品四虎免费观看国产高清 | 99综合之综合久久伊人 | 国产在线精品国自产拍影院同性 | 久久久久中文字幕 | 三级黄网 | 成人午夜精品网站在线观看 | 狠狠亚洲婷婷综合色香五 | 国产91成人精品亚洲精品 | 亚欧三级 | 九九久久国产精品免费热6 九九久久精品 | 91tm视频| 亚洲欧洲色天使日韩精品 | 高清国产美女一级a毛片 | 黑人www| 国产高清国内精品福利色噜噜 | 男人女人无遮掩免费视频 | 91视频免费看 | 欧美日本韩国一区 | 美女黄区 | 国产激情小视频 | 国产成人鲁鲁免费视频a | 涩涩涩涩涩涩涩涩涩涩 | 91精品国产自产在线观看 | 国产女女视屏免费 | julia一区二区三区中文字幕 | 婷婷久操| 久久精品国产久精国产 | 视色4se视频在线观看 | 亚洲日本1区2区3区二区 | 四虎最新紧急入口 | 日韩一区国产二区欧美三区 | 日日插夜夜操 | 激情五月综合网 | 手机看片自拍日韩日韩高清 | 在线精品国内视频秒播 |