XmlNodeReader.Skip Method ()


Skips the children of the current node.

Namespace:   System.Xml
Assembly:  System.Xml (in System.Xml.dll)

public override void Skip()


In the .NET Framework 2.0, the recommended practice is to create XmlReader instances using the XmlReaderSettings class and the Create method. This allows you to take full advantage of all the new features introduced in the .NET Framework. For more information, see the Remarks section in the XmlReader reference page.

For example, suppose you have the following XML input:

<a name="bob" age="123">

If the reader is positioned on the "<a>" node or any of its attributes, calling Skip positions the reader to the "<b>" node.

If the reader is positioned on a leaf node already (such as element "x" or the text node "abc"), calling Skip is the same as calling Read.

This method checks for well-formed XML.

The following example reads the price element node in the XML document.

using System;
using System.IO;
using System.Xml;

public class Sample 
  public static void Main()
    XmlNodeReader reader = null;

       //Create and load the XML document.
       XmlDocument doc = new XmlDocument();
       doc.LoadXml("<!-- sample XML -->" +
                   "<book>" +
                   "<title>Pride And Prejudice</title>" +
                   "<price>19.95</price>" +

       //Load the XmlNodeReader 
       reader = new XmlNodeReader(doc);

       reader.MoveToContent(); //Move to the book node.
       reader.Read();  //Read the book start tag.
       reader.Skip();   //Skip the title element.

       Console.WriteLine(reader.ReadOuterXml());  //Read the price element.


        if (reader != null)
} // End class

.NET Framework
Available since 1.1
Return to top