I should clarify that this seems to be quite a silly way to achieve the desired result. If you must use an XmlTextWriter, then there is hardly any point doing it via LInQ. All of the InnerXml of the root element is already available as a string.
On Aug 26, 8:05 pm, Cerebrus <[email protected]> wrote: > Something like : > > --- > Public Sub Test1() > Using writer As New XmlTextWriter("C:\TestOut.xml", > System.Text.Encoding.UTF8) > writer.WriteStartElement("Level0") > Dim innerXML As String = Test2() > writer.WriteRaw(innerXML) > writer.WriteEndElement() > End Using > End Sub > > Private Function Test2() As String > Dim xDoc = XDocument.Load("C:\TestIn.xml") > Dim elements As IEnumerable(Of XElement) = _ > From element In xDoc.Descendants("Element") _ > Where element.Attribute("ID").Value = "" _ > Select element > > Dim sb As New StringBuilder() > For Each el As XElement In elements > sb.Append(el.ToString()) > Next > Return sb.ToString() > End Function > > --- >
