IsEmptyElement (Compact 7)
3/12/2014
This method lets the client determine the difference between elements that have a closing tag but do not contain content, and elements that do not have a closing tag..
Syntax
BOOL IsEmptyElement ();
Return Value
This method returns TRUE if the current element ends with />
; otherwise this method returns FALSE.
Remarks
IsEmptyElement returns FALSE for the following element:
<element attribute="123"></element>
IsEmptyElement returns TRUE for the following element:
<element attribute="123"/>
When writing elements, an XmlNodeType_EndElement node is not generated for empty element start tags.
If the method is not applicable, it will return FALSE.
The following code tests whether the reader is currently on an empty element:
if (FAILED(hr = pReader->GetPrefix(&pwszPrefix, &cwchPrefix)))
{
wprintf(L"Error getting prefix, error is %08.8lx", hr);
return -1;
}
if (FAILED(hr = pReader->GetLocalName(&pwszLocalName, NULL)))
{
wprintf(L"Error getting local name, error is %08.8lx", hr);
return -1;
}
if (cwchPrefix > 0)
wprintf(L"Element: %s:%s\n", pwszPrefix, pwszLocalName);
else
wprintf(L"Element: %s\n", pwszLocalName);
if (FAILED(hr = WriteAttributes(pReader)))
{
wprintf(L"Error writing attributes, error is %08.8lx", hr);
return -1;
}
if (pReader->IsEmptyElement() )
wprintf(L" (empty)");