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 " /> 精品一区二区三区四区五区六区 ,国产精品入口,国产精品一区二区不卡

四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

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)記有誤,請第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: a级性片| 生活频道| 王馨可| 五年级语文上册第八课笔记| vs岚| 谍影非凡 电影| 蓝燕3d电影《极乐宝鉴》在线观看| 性的秘密| 布袋头| 水怪电影| 有为有不为思维导图| 许颖| 孤岛惊魂| 少爷和我短剧| 又什么又什么四字成语| 变形金刚2演员表| 小敏家| 女子露胸| 柳堡的故事演员表| 宋小莹| silk铃木一彻| 二年级下册数学期末考试试卷可打印| 大丈夫日记| 风花电影完整版免费观看| 明日战记| 林岚| 山西少儿频道| 沉默的羔羊1| 白浩| 浙江卫视台节目表| 高嘉慧| kaya| 接吻教学视频| 草逼啊啊啊| 陈冠希的艳照门| 奔向所有时空的你电视剧在线观看| 夜半2点钟| 特种部队电影全集观看| 热带雨林电影完整版播放| 张紫妍未删减版视频| 大地资源中文字幕第3页|