WriteStartElement (Compact 7)
3/12/2014
This method writes out the specified start tag and associates it with the specified namespace.
Syntax
HRESULT WriteStartElement (
const WCHAR* pwszPrefix,
const WCHAR* pwszLocalname,
const WCHAR* pwszNamespaceUri
);
Parameters
- pwszPrefix
The namespace prefix of the element. A NULL value is the same as an empty string.
- pwszLocalname
The local name of the element. A NULL value is not valid.
- pwszNamespaceUri
The namespace URI of the element. NULL is the same as an empty string.
Return Value
This method returns S_OK if no error is generated.
Remarks
After you call this method, an application can either write attributes or write content. To write content, use WriteComment, WriteString, or WriteStartElement.
A program must call WriteEndElement 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 code creates an element:
if (FAILED(hr = pWriter->WriteStartElement(NULL, L"containsEntity", NULL)))
{
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()))
{
wprintf(L"Error, Method: WriteEndElement, error is %08.8lx", hr);
return -1;
}
Calling WriteStartDocument is the same as calling WriteProcessingInstruction passing a name of "xml" as an argument. Therefore, a program cannot successfully call both WriteStartDocument and WriteProcessingInstruction passing the name "xml" for the same document. It is valid to call WriteStartDocument and WriteProcessingInstruction for processing instructions that have a name other than the name "xml".
See Also
Reference
IXmlWriter Methods
WriteComment
WriteString
WriteStartElement
WriteEndElement
WriteFullEndElement
IXmlWriter Properties