WriteNode (IXmlWriterLite)
Copies the current node from the specified source IXmlReader to the IXmlWriterLite. 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.
Syntax
HRESULT WriteNode (IXmlReader pReader, BOOL fWriteDefaultAttributes);
Arguments
pReader
The reader to read from.
fWriteDefaultAttributes
Specifies whether to also copy the default attributes from the specified IXmlReader
.
Return Value
Returns S_FALSE 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 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 that is 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. This includes 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 WriteAttributeString method. This node type is primarily used when documents are read and parsed. |
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 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.
Requirements
Header: XmlLite.h
Library: XmlLite.lib
See Also
WriteNodeShallow (IXmlWriterLite)
WriteString (IXmlWriterLite)
IXmlWriterLite Methods