Share via


WriteNode (Compact 7)

3/12/2014

This method 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 the child nodes of the current node. If the reader is in the initial state, this method copies all the nodes in the reader.

Syntax

HRESULT WriteNode (
    IXmlReader pReader, 
    BOOL fWriteDefaultAttributes
);

Arguments

  • pReader
    The reader from which to read
  • fWriteDefaultAttributes
    Specifies whether to also copy the default attributes from the specified IXmlReader

Return Value

This method returns S_OK if no error is generated.

Remarks

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 might have been resolved by that resolver. For the IXmlReader, the resolved entity is a child node of the Entity Reference node.

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

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 ndoe

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 ended when they are written.

XmlDeclaration

Writes out the XmlDeclaration node

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.

See Also

Reference

IXmlWriter Methods
IXmlReader
IXmlWriter
IXmlResolver
WriteAttributes
WriteAttributeString
WriteString
WriteNodeShallow
IXmlWriter Properties