There's two things you can do. You can create a custom object tree and then serialize that to XML in one go, or create an XML DOM object and populate that. Which you want depend on what else you're going to do with the data. I'm going to assume the XML DOM approach here.
The basic approach is to split the path string, iterate over the components, check if a node already exists and if not, add it.
Private Sub AddPath(ByVal doc As XmlDocument, ByVal path As String)
Dim components() As String = path.Split(">"c)
Dim elt As XmlElement = doc.DocumentElement
For Each component As String In components
Dim newElt As XmlElement = CType(elt.SelectSingleNode("node[@id='" & component.Trim() & "']"), XmlElement)
If newElt Is Nothing Then
newElt = doc.CreateElement("node")
newElt.SetAttribute("id", component.Trim())
elt.AppendChild(newElt)
End If
elt = newElt
Next
End Sub
I'm sure there's a ton of ways to make that faster but this should get you started at least. You can then use it like this:
Dim doc As New XmlDocument
' Create XML declaration
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", Nothing))
' Create document element
doc.AppendChild(doc.CreateElement("nodes"))
AddPath(doc, "11 > 7 > 2")
AddPath(doc, "11 > 7 > 8 > 5")
AddPath(doc, "11 > 7 > 8 > 6 > 2")
Console.WriteLine(doc.OuterXml)
If you want to write it to a file but have it nicely indented and stuff, you can do this:
Dim settings As New XmlWriterSettings
settings.Indent = True
Using writer As XmlWriter = XmlWriter.Create("foo.xml", settings)
doc.Save(writer)
End Using