XNode.WriteTo writes this node to an XmlWriter. : XmlWriter « XML « VB.Net






XNode.WriteTo writes this node to an XmlWriter.

 
Imports System
Imports System.Text


Imports System.Xml
Imports System.Xml.Schema

Class MainClass

    Shared Sub Main()

        Dim sb As StringBuilder = New StringBuilder()
        Dim xws As XmlWriterSettings = New XmlWriterSettings()
        xws.OmitXmlDeclaration = True
        xws.Indent = True

        Using xw = XmlWriter.Create(sb, xws)
            xw.WriteStartElement("Root")
            Dim child1 As XElement = <Child>
                                         <GrandChild>some</GrandChild>
                                     </Child>
            child1.WriteTo(xw)
            Dim child2 As XElement = <AnotherChild>
                                         <GrandChild>different</GrandChild>
                                     </AnotherChild>
            child2.WriteTo(xw)
            xw.WriteEndElement()
        End Using

        Console.WriteLine(sb.ToString())
    End Sub

End Class

   
  








Related examples in the same category

1.Append new child to the XmlWriter
2.Create XmlWriter using XmlWriter.Create method.
3.Saves the XML document to the specified XmlWriter.
4.Saves all the children of the node to the specified XmlWriter.
5.Saves the current node to the specified XmlWriter.
6.XmlWriter.Close closes this stream and the underlying stream.
7.Creates XmlWriter using the specified stream.
8.XmlWriter.Create creates a new XmlWriter instance using the stream and XmlWriterSettings object.
9.Creates a new XmlWriter instance using the specified filename.
10.Creates XmlWriter instance using the TextWriter and XmlWriterSettings objects.
11.XmlWriter.WriteBase64 encodes specified binary bytes as Base64
12.XmlWriter.WriteBinHex encodes specified binary bytes as BinHex
13.XmlWriter.WriteEndElement closes one element and pops the corresponding namespace scope.
14.XmlWriter.WriteNode copies data from the reader to the writer
15.XmlWriter.WriteNode (XPathNavigator, Boolean)
16.XmlWriter.WriteProcessingInstruction writes out a processing instruction
17.XmlWriter.WriteString writes the given text content.
18.XmlWriter.WriteValue
19.XPathNavigator.InsertBefore returns an XmlWriter
20.XPathNavigator.PrependChild returns XmlWriter to create a new child node
21.XDocument.Save Method (XmlWriter) serializes this XDocument to an XmlWriter.
22.XDocument.WriteTo writes this document to an XmlWriter.
23.XElement.Save (XmlWriter) serializes this element to an XmlWriter.
24.XElement.WriteTo writes this element to an XmlWriter.