2
我正在做我的第一個項目與VisualBasic。包括編寫XML並保存。這是我的代碼:如何使用VisualBasic編寫XML模式實例?
Imports System
Imports System.Xml
Public Class Form1
Private Sub saveXML_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles saveXML.Click
Dim settings As New XmlWriterSettings()
settings.Indent = True
Dim XmlWrt As XmlWriter = XmlWriter.Create("C:\Documents and Settings\dpradell\MyName.xml", settings)
With XmlWrt
.WriteStartDocument()
.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema")
.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")
而與此部分:
.WriteStartElement("Production")
.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema")
.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")
我想寫這個聲明:
<Production xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
但是好像 「:」 字符不允許是包含在屬性中。 我該如何解決它? 非常感謝!
謝謝!工作正常 –