WriteAttributes
Copies attributes from the specified source IXmlReader to the IXmlWriter.
Syntax
HRESULT WriteAttributes (IXmlReader * pReader, BOOL fWriteDefaultAttributes);
Arguments
pReader
The reader to copy the attributes from. This argument cannot be NULL.
fWriteDefaultAttributes
Specifies whether to also copy the default attributes from the reader.
Return Value
Returns S_OK if no error is generated.
Remarks
The attributes copied depend on the current position of the reader:
If the reader is positioned on an element node, this method copies all of the attributes contained by the element.
If the reader is positioned on an attribute node, this method copies the current attribute and the rest of the attributes contained by the element.
If the reader is positioned on an
XmlNodeType_XmlDeclaration
, this method writes out all the attributes of the declaration.If the reader is positioned on any other node type, calling this method has no effect.
The following code writes out all the attributes located at the current position in the specified reader:
if (FAILED(hr = pWriter->WriteStartElement(NULL, L"sub", NULL)))
{
wprintf(L"Error, Method: WriteStartElement, error is %08.8lx", hr);
return -1;
}
if (FAILED(hr = pWriter->WriteAttributeString(NULL, L"myAttr", NULL,
L"1234")))
{
wprintf(L"Error, Method: WriteAttributeString, error is %08.8lx", hr);
return -1;
}
Requirements
Header: XmlLite.h
Library: XmlLite.lib