Export (0) Print
Expand All

XmlWriter.WriteNode Method (XPathNavigator, Boolean)

Copies everything from the XPathNavigator object to the writer. The position of the XPathNavigator remains unchanged.

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

abstract WriteNode : 
        navigator:XPathNavigator * 
        defattr:bool -> unit  
override WriteNode : 
        navigator:XPathNavigator * 
        defattr:bool -> unit


Type: System.Xml.XPath.XPathNavigator

The XPathNavigator to copy from.

Type: System.Boolean

true to copy the default attributes; otherwise, false.


navigator is a null reference (Nothing in Visual Basic).


An XmlWriter method was called before a previous asynchronous operation finished. In this case, InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.”

The following table shows the supported XPath node types for this method.


WriteNode Behavior


Writes out all the nodes irrespective of type. That is, the writer consumes the XPathNavigator and writes out all the nodes from the root node (including attributes, processing instructions, comments and so on.)


Writes out the element node and any attribute nodes.


No operation. Use WriteStartAttribute or WriteAttributeString instead.


Writes out the text node.


No operation. Use the WriteStartAttribute or WriteAttributeString method to write the namespace declaration.


Writes out the processing instruction node.


Writes out the comment node.


Writes out the significant white space node.


Writes out the white space node.

For the asynchronous version of this method, see WriteNodeAsync.

The following example uses the WriteNode method to copy the first book node from a document and write it to the console.

No code example is currently available or this language may not be supported.

The example uses the books.xml file as input.

<?xml version="1.0" encoding="utf-8" ?> 
    <book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">
        <title>The Autobiography of Benjamin Franklin</title>
    <book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">
        <title>The Confidence Man</title>
    <book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">
        <title>The Gorgias</title>

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft