Normalizes all descendent elements; combines two or more adjacent text nodes into one unified text node.
Visual Basic Syntax
oXMLDOMElement.normalize
C/C++ Syntax
HRESULT normalize(void);
C/C++ Return Values
S_OK
Value returned if successful.
E_FAIL
Value returned if an error occurs.
Remarks
This method converts all text node descendants of this element (at any depth) into a "normal" form where no text nodes are adjacent. In normal form, text nodes can be separated only by markup (such as tags, comments, processing instructions, CDATA sections, and entity references). The normal form is useful for operations that require a particular document tree structure, and ensures that the DOM view of a document is identical when saved and reloaded.
Collapsed node objects are automatically deleted.
C/C++ Example
BOOL DOMElementNormalize()
{
BOOL bResult = FALSE;
IXMLDOMElement *pIXMLDOMElement = NULL;
IXMLDOMDocument *pIXMLDOMDocument = NULL;
HRESULT hr;
try
{
// create an instance of DOMDocument and initialize pIXMLDOMDocument
// load/create an XML fragment
hr = pIXMLDOMDocument->get_documentElement(&pIXMLDOMElement);
SUCCEEDED(hr) ? 0 : throw hr;
if(pIXMLDOMElement )
{
hr = pIXMLDOMElement->normalize();
if(SUCCEEDED(m_hr))
bResult = TRUE;
pIXMLDOMElement->Release();
}
}
catch(...)
{
if(pIXMLDOMElement)
pIXMLDOMElement->Release();
DisplayErrorToUser();
}
return bResult;
}