WriteNode

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);
pReader

The reader to read from.

fWriteDefaultAttributes

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.

XmlNodeType

Description

None

This 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.

Element

The 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.

Attribute

This 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.

Text

The writer writes out the text node.

CDATA

The writer writes out the CDATA section node.

EntityReference

The writer writes the Entity Reference node.

ProcessingInstruction

The writer writes the PI node.

Comment

The writer writes the Comment node.

DocumentType

The writer writes the DocType node.

Whitespace

The writer writes the Whitespace node.

SignificantWhitespace

The writer writes the Significant Whitespace node.

EndElement

No operation

EndEntity

This node type is not supported when writing. Entities are automatically ending when writing them.

XmlDeclaration

Writes out the XmlDeclaration node.

Note 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

Show:
© 2014 Microsoft. All rights reserved.