I’m trying to append a list of “Columns” to this xml file:
<?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>
What I have so far:
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
Basically, I know what ever goes in the for each isn’t going to append the item; it’s just going to write the last value of the list. Is there a way to append these items?
Thanks
Try this: