Append new child to the XmlWriter : XmlWriter « XML « VB.Net






Append new child to the XmlWriter

   

Public Class Example8

    Shared  Sub Main
        Dim doc As System.Xml.XmlDocument
        Dim editor, editor2 As System.Xml.XPath.XPathNavigator
        Dim writer As System.Xml.XmlWriter

        doc = New System.Xml.XmlDocument
        doc.Load("pubs.xml")

        For Each editor In doc.CreateNavigator.Select("/pubs/titles[authors/@au_lname='Green']")
            editor2 = editor.SelectSingleNode("authors[@au_lname!='Green']")
            If Not IsNothing(editor2) Then
                editor2.DeleteSelf()
            End If

            writer = editor.AppendChild()
            writer.WriteStartElement("authors")
            writer.WriteAttributeString("au_lname", "A")
            writer.WriteAttributeString("au_fname", "B")
            writer.Close()
        Next

        doc.Save("output.xml")
    End Sub
End Class

   
    
    
  








Related examples in the same category

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