WriteProcessingInstruction
Writes a processing instruction.
Syntax
HRESULT WriteProcessingInstruction (const WCHAR * pwszName, const WCHAR * pwszText);
Arguments
pwszName
The name of the processing instruction. This parameter cannot be NULL.
pwszText
The text content of the processing instruction. NULL is equivalent to an empty string.
Return Value
Returns S_OK if no error is generated.
Remarks
The writer creates a processing instruction by writing the provided name and text with a space after the name.
If the pwszText
parameter is NULL, this method returns S_OK and writes a processing instruction with no text content.
If the text block provided contains the characters "?>"
, which denote the end of a processing instruction, the writer inserts a space after the "?
" character. This change to the text prevents the writer from producing an XML document that is not well-formed.
The following code shows the use of WriteProcessingInstruction
:
if (FAILED(hr = pWriter->WriteProcessingInstruction(L"xml-stylesheet",
L"href=\"mystyle.css\" title=\"Compact\" type=\"text/css\"")))
{
wprintf(L"Error, Method: WriteProcessingInstruction, error is %08.8lx", hr);
return -1;
}
For a more detailed example of WriteProcessingInstruction
, see Write an XML Document using XmlLite.
Requirements
Header: XmlLite.h
Library: XmlLite.lib