XmlNode.InsertAfter inserts the specified node immediately after the specified reference node. : XmlNode « XML « VB.Net






XmlNode.InsertAfter inserts the specified node immediately after the specified reference node.

 

Option Strict
Option Explicit

Imports System
Imports System.IO
Imports System.Xml

Public Class Sample
    Public Shared Sub Main()

        Dim doc As New XmlDocument()
        doc.LoadXml("<book genre='Computer' ISBN='1-111111-57-5'>" & _
                    "<title>C#</title>" & _
                    "</book>")
        Dim root As XmlNode = doc.DocumentElement

        Dim elem As XmlElement = doc.CreateElement("price")
        elem.InnerText = "9.9"

        root.InsertAfter(elem, root.FirstChild)

        doc.Save(Console.Out)
    End Sub 'Main 
End Class 'Sample

   
  








Related examples in the same category

1.Creates an XmlNode with the specified node type, Name, and NamespaceURI.
2.Creates an XmlNode with the specified XmlNodeType, Name, and NamespaceURI.
3.Creates a XmlNode with the specified XmlNodeType, Prefix, Name, and NamespaceURI.
4.Returns an XmlNodeList containing a list of all descendant elements that match the specified Name.
5.Creates XmlNode based on the information in XmlReader
6.Returns an XmlNodeList containing a list of all descendant elements that match the specified Name.
7.XmlNode.CloneNode creates a duplicate of the node.
8.Provides support for the for each style iteration over the nodes in the XmlNode.
9.XmlNode.GetPrefixOfNamespace
10.XmlNode.InsertBefore inserts the specified node immediately before the specified reference node.
11.XmlNode.Item gets the first child element with the specified Name.
12.XmlNode.LastChild gets the last child of the node.
13.XmlNode.NextSibling gets the node immediately following this node.
14.XmlNode.SelectNodes Method (String, XmlNamespaceManager)
15.Selects the first XmlNode that matches the XPath expression.
16.XmlNode.SelectSingleNode Method (String, XmlNamespaceManager)
17.XmlNode.WriteContentTo saves all the child nodes of the node to the specified XmlWriter.
18.XmlNode.WriteTo saves the current node to the specified XmlWriter.
19.Create XmlTextReader class with the specified string, XmlNodeType, and XmlParserContext.