急急急!有关在.net 中创建一个新的xml文件

Brune 2003-12-11 10:05:33
Dim mydom As New Xml.XmlDocument()
Dim GetFeature, As Xml.XmlElement
GetFeature = mydom.CreateElement("GetFeature")
GetFeature.SetAttribute("version", "1.0.0")
GetFeature.SetAttribute("service", "WFS")
GetFeature.SetAttribute("xmlns", "http://www.opengis.net/wfs")
GetFeature.SetAttribute("xmlns:ogc", "http://www.opengis.net/ogc")
mydom.Save("c:\filter.xml")
请问为什么写出的xml文件没有头 <?xml version="1.0" ?> 怎样加上去??
...全文
22 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Brune 2003-12-11
  • 打赏
  • 举报
回复
THank you
待接入自我 2003-12-11
  • 打赏
  • 举报
回复
因此,你的完整代码应该是
dim mydom as new xml.xmldocument()
Dim GetFeature, As Xml.XmlElement
Dim newDec As XmlDeclaration

newDec = mydom.CreateXmlDeclaration("1.0", Nothing, Nothing)
mydom.AppendChild(newDec)

GetFeature = mydom.CreateElement("GetFeature")
GetFeature.SetAttribute("version", "1.0.0")
GetFeature.SetAttribute("service", "WFS")
GetFeature.SetAttribute("xmlns", "http://www.opengis.net/wfs")
GetFeature.SetAttribute("xmlns:ogc", "http://www.opengis.net/ogc")
mydom.AppendChild(GetFeature)
mydom.Save("c:\filter.xml")

待接入自我 2003-12-11
  • 打赏
  • 举报
回复
Dim newDec As XmlDeclaration
newDec = doc.CreateXmlDeclaration("1.0", Nothing, Nothing)
doc.AppendChild(newDec)

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧