我是一位名叫xml和net的开端人。 我有一系列检查箱,我希望根据用户选择编制Xml文档。 我希望Xml文档也这样做。
<?xml version="1.0" encoding="utf-8"?>
<FILTER xmlns:x="urn:1">
<CATEGORY Name="Year">
<SELECTED Value="2011/2010" />
<SELECTED Value="2010/2009" />
<SELECTED Value="2009/2008" />
</CATEGORY>
<CATEGORY Name="Grade">
<SELECTED Value="Kindergarten 1" />
</CATEGORY>
</FILTER>
但我只想这样做。
<?xml version="1.0" encoding="utf-8"?>
<FILTER xmlns:x="urn:1">
<CATEGORY Name="Year">
<SELECTED Value="2011/2010" />
</CATEGORY>
<CATEGORY Name="Year">
<SELECTED Value="2010/2009" />
</CATEGORY>
<CATEGORY Name="Year">
<SELECTED Value="2009/2008" />
</CATEGORY>
<CATEGORY Name="Grade">
<SELECTED Value="Kindergarten 1" />
</CATEGORY>
</FILTER>
这是用于制造Xml文档的VB代码。 请告诉我我我什么是失踪的。 非常感谢帮助。
Dim itemacademicyear As ListItem
Dim itemgrade As ListItem
Dim w As New XmlTextWriter(Server.MapPath("items.xml"), Encoding.UTF8)
w.Formatting = Formatting.Indented
w.WriteStartDocument()
w.WriteStartElement("FILTER")
w.WriteAttributeString("xmlns", "x", Nothing, "urn:1")
For Each itemacademicyear In cblacademicyear.Items
If itemacademicyear.Selected = True Then
lblselected.Text = lblselected.Text & itemacademicyear.Text & " " & "<a href= # >remove</a>" & "<BR>"
xml bit
w.WriteStartElement("CATEGORY")
w.WriteAttributeString("Name", "Year")
w.WriteStartElement("SELECTED")
w.WriteAttributeString("Value", itemacademicyear.Text)
w.WriteEndElement()
w.WriteEndElement()
End If
Next