WriteStartElement (IXmlWriterLite)
Writes out the specified start tag.
Syntax
HRESULT WriteStartElement (
const WCHAR * pwszQNname,
UINT cwszQName);
Arguments
pwszQName
The qualified name of the element to open. NULL causes an error.
cwszQName
The length of the element name in wide-character units.
Return Value
Returns S_OK if no error is generated.
Remarks
After calling this method, an application can either write attributes or write content. To write content, use WriteComment, WriteString, or WriteStartElement
.
A program must call WriteEndElement or WriteFullEndElement to close the element. The WriteEndElement
method might write a full end tag, or it might close the element by using the short form. The WriteFullEndElement
method always writes a full end tag.
The following example creates an element:
if (FAILED(hr = pWriter->WriteStartElement(L"containsEntity", 14)))
{
wprintf(L"Error, Method: WriteStartElement, error is %08.8lx", hr);
return -1;
}
if (FAILED(hr = pWriter->WriteEntityRef(L"myEntity")))
{
wprintf(L"Error, Method: WriteEntityRef, error is %08.8lx", hr);
return -1;
}
if (FAILED(hr = pWriter->WriteEndElement(L"containsEntity", 14)))
{
wprintf(L"Error, Method: WriteEndElement, error is %08.8lx", hr);
return -1;
}
For a complete code example that uses WriteStartElement
, see Universal Windows Platform (UWP) XmlLite sample.
Requirements
Header: XmlLite.h
Library: XmlLite.lib