Freigeben über


WriteElementString

 

Writes out an element with the specified prefix, name, namespace, and value.

Syntax

  
HRESULT WriteElementString (  
    const WCHAR * pwszPrefix,  
    const WCHAR * pwszLocalName,  
    const WCHAR * pwszNamespaceUri,  
    const WCHAR * pwszValue);  

Arguments

pwszPrefix
The namespace prefix of the element. NULL is equivalent to an empty string.

pwszLocalName
The local name of the element. NULL will result in an error.

pwszNamespaceUri
The namespace URI of the element. NULL is equivalent to an empty string.

pwszValue
The value of the element. NULL indicates that there is no content to write. In contrast, an empty string indicates that this element has an empty value.

Return Value

Returns S_OK if no error is generated.

Remarks

The following code shows the use of WriteElementString:

if (FAILED(hr = pWriter->WriteElementString(NULL, L"myElement", NULL, L"myValue")))  
{  
    wprintf(L"Error, Method: WriteElementString, error is %08.8lx", hr);  
    return -1;  
}  

For a more detailed example of WriteElementString, see Write an XML Document using XmlLite.

Requirements

Header: XmlLite.h

Library: XmlLite.lib

See Also

IXmlWriter Methods