我正在尝试将“列”列表附加到此 xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<Conf>
<name List="A">
<columns>1</columns>
<columns>2</columns>
<columns>3</columns>
<columns>4</columns>
<columns>5</columns>
<columns>6</columns>
</name>
<name List="B">
<columns>1</columns>
<columns>2</columns>
<columns>3</columns>
<columns>4</columns>
<columns>5</columns>
<columns>6</columns>
<columns>9</columns>
</name>
</Conf>
到目前为止我所拥有的:
Sub NewNodeInXMLFile(ByVal strPath As String, ByVal PriceList As String, ByVal columns As List(Of String))
Dim XMLd As New XmlDocument
XMLd.Load(strPath)
Dim xmlEl As XmlElement = XMLd.CreateElement("name")
Dim xmlAttr As XmlAttribute = XMLd.CreateAttribute("List")
xmlAttr.Value = PriceList
xmlEl.Attributes.Append(xmlAttr)
For Each x In columns
xmlEl.InnerXml = "<columns></columns>"
xmlEl.Item("columns").InnerText = x
'//what goes in here to append this item?
Next
XMLd.DocumentElement.AppendChild(xmlEl)
XMLd.Save(strPath)
End Sub
基本上,我知道 for each 中的内容不会附加该项目;它只是要写入列表的最后一个值。有没有办法附加这些项目?
谢谢