Dim doc As XDocument = XDocument.Load("XmlFile.xml")
' First find the root node
Dim Root As XElement = doc.Root
' Now get the sub tree FrameElements
Dim FrameElements As XElement = Root.Descendants("FrameElements").SingleOrDefault()
' Now get the sub tree Interactions
Dim Interactions As XElement = Root.Descendants("Interactions").SingleOrDefault()
' Create the new XDocument
Dim resultDoc As New XDocument(New XDeclaration("1.0", "utf-8", "yes"))
' Create a root node
Dim Root2 As New XElement("Root")
' Add Root to the document
resultDoc.Add(Root2)
Root2.Add(FrameElements)
Root2.Add(Interactions)
' Write the new xml document to a file
resultDoc.Save("XmlFileResult.xml")
|