Copies the current node from the specified source IXmlReader to the IXmlWriter. This method moves the IXmlReader source to the start of the next sibling node, reading all of the child nodes of the current node. If the reader is in the initial state, this method copies all of the nodes in the reader.

HRESULT WriteNode (IXmlReader pReader, BOOL fWriteDefaultAttributes);  

The reader to read from.

Specifies whether to also copy the default attributes from the specified IXmlReader.

Returns S_FALSE if no error is generated.

When the IXmlReader is already at the end of the input, or has been closed, the reader contains no nodes to be written. In this case, this method does not write any nodes to the writer.

When the IXmlReader has an IXmlResolver specified, Entity Reference nodes may have been resolved with that resolver. For the IXmlReader, the resolved entity is a child node of the Entity Reference node.

Notice that attribute nodes have no siblings, but are instead considered as metadata contained by element nodes. Therefore, attribute nodes cannot be copied individually.

The specified IXmlReader can supply default attributes from a Document Type Definition (DTD). When the fWriteDefaultAttributes property is set to TRUE, all default values from the supplied data source are written to the output. When the fWriteDefaultAttributes property is set to FALSE, no default values from the supplied data source are written to the output.

The following table shows the actions this method takes, depending on the XmlNodeType of the current node.

NoneThis occurs when the reader is in the XmlReaderState_Initial state. If there is no XmlNodeType, the writer writes out all the nodes regardless of type. That is, the writer consumes the IXmlReader and writes out all the nodes read, including attributes, processing instructions, comments, and so on.
ElementThe writer writes out the element node and all child nodes of the element. It also writes out all attributes of all nodes that are written out.
AttributeThis node type is not directly supported when writing. Attributes are written out when their parent element is written. To write individual attributes, use the WriteAttributes method or the or WriteAttributeString method. This node type is primarily used when reading and parsing documents.
TextThe writer writes out the text node.
CDATAThe writer writes out the CDATA section node.
EntityReferenceThe writer writes the Entity Reference node.
ProcessingInstructionThe writer writes the PI node.
CommentThe writer writes the Comment node.
DocumentTypeThe writer writes the DocType node.
WhitespaceThe writer writes the Whitespace node.
SignificantWhitespaceThe writer writes the Significant Whitespace node.
EndElementNo operation
EndEntityThis node type is not supported when writing. Entities are automatically ending when writing them.
XmlDeclarationWrites out the XmlDeclaration node.
System_CAPS_ICON_note.jpg Note

If the specified IXmlReader returns white space and the XmlWriterProperty_Indent property is set to TRUE, both the reader and the writer can indent nodes.

Platforms: Windows Server 2008, Windows Vista, Windows Server 2003 Service Pack 1 or later, Windows XP Service Pack 2 or later, Windows Server 2008 R2, Windows 7.

Header: XmlLite.h

Library: XmlLite.lib

IXmlWriter Methods