Share via


WriteProcessingInstruction (IXmlWriterLite)

 

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 without text content.

If the text block provided contains the characters "?>", which signify 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 example 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 complete code example that uses WriteProcessingInstruction, see Universal Windows Platform (UWP) XmlLite sample.

Requirements

Header: XmlLite.h

Library: XmlLite.lib

See Also

IXmlWriterLite Methods