Hi, I have an xml file that needs to be imported. The file has items, and the items have sub-items (these subitems can change, so it must be dynamic).
<items>
<item>
<id>4</id>
<voornaam>name</voornaam>
<achternaam></achternaam>
<email>support@mail.nl</email>
<...>
</item>
<item>
<id>5</id>
<voornaam>Site</voornaam>
<achternaam>Administrator</achternaam>
<email>support@mail.nl</email>
<...>
</item>
<...>
</items>
What I have so far:
Dim root As XmlNode
root = xml.DocumentElement
Dim itemsNode As XmlNode
Dim itemNode As XmlNode
Dim returnItemNode As XmlNode
Dim val As XmlNode
Dim key As String
Dim value As String
// 'we start with 1 because the first xml element is the <return> element
For items As Integer = 1 To root.ChildCount-1
itemsNode = root.Child(items)
For item As Integer = 0 To itemsNode.ChildCount-1
itemNode = itemsNode.Child(item)
For subItem As Integer = 0 To itemNode.ChildCount-1
if (itemNode.Child(subItem).ChildCount > 0) Then
key = itemNode.Child(subItem).LocalName
value = itemNode.Child(subItem).FirstChild.Value
dim d as new dictionary
d.Value("key") = key
d.Value("value") = value
myglobal.data.Append(d)
End
Next
Next
Next
Now my result in myglobal.data is:
dictionary(with key and value)
dictionary(with key and value)
dictionary(with key and value)
...
What I need is an array like this:
item1
dictionary(with key and value)
dictionary(with key and value)
item2
dictionary(with key and value)
dictionary(with key and value)
That way I can loop my data and create an insert statement for each item.
Thanks!