Dim names() As String = {"one", "two", "three"}
Dim xml As XElement = Nothing
For Each name In names
If xml Is Nothing Then
xml = New XElement(name)
Else
xml.Add(New XElement(name)
End If
Next
The above code will create something like this:
<One>
<Two />
<Three />
</One>
What I need is something like this:
<One>
<Two>
<Three />
</Two>
</One>
I tried using xml.Elements.Last.Add(New XElement(name))
, but the Last
method isn't necessarily returning the last element for some reason.
Thanks!