Breaks this text node into two text nodes at the specified offset, and inserts the new text node into the tree as a sibling that immediately follows this node.
Visual Basic Syntax
Set objXMLDOMText = oXMLDOMText.splitText(offset)
C/C++ Syntax
HRESULT splitText(
long offset,
IXMLDOMText **rightHandTextNode);
Parameters
offset
[in]
Number of characters at which to split this text node into two nodes, starting from zero.
rightHandTextNode
[out]
New text node.
C/C++ Return Values
S_OK
Value returned if successful.
S_FALSE
Value when returning null.
E_FAIL
Value returned if an error occurs.
Remarks
If you specify an offset of zero, the first text node is empty and the right-hand text node contains the previous contents of the node.
If you specify an offset beyond the end of the string, a new, empty right-hand text node is created.
C/C++ Example
IXMLDOMText *pIXMLDOMTextTemp = NULL;
IXMLDOMText *pIXMLDOMText = NULL;
IXMLDOMNode *pIXMLDOMNodeTemp = NULL;
IXMLDOMElement *pIXMLDOMElement = NULL;
IXMLDOMNode *pIXMLDOMNode = NULL;
DOMNodeType DOMNodeTyp;
VARIANT varValue;
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->QueryInterface(IID_IXMLDOMNode, (void **)&pIXMLDOMNode);
SUCCEEDED(hr) ? 0 : throw hr;
pIXMLDOMElement->Release();
pIXMLDOMElement = NULL;
while(pIXMLDOMNode)
{
hr = pIXMLDOMNode->get_nodeType(&DOMNodeTyp);
if(SUCCEEDED ( hr) && (DOMNodeTyp == NODE_TEXT))
{
hr = pIXMLDOMNode->QueryInterface(IID_IXMLDOMText, (void**)&pIXMLDOMText);
SUCCEEDED(hr) ? 0 : throw hr;
if(pIXMLDOMText)
{
hr = pIXMLDOMText->splitText(2, &pIXMLDOMTextTemp);
if(SUCCEEDED(hr) && pIXMLDOMTextTemp)
{
hr = pIXMLDOMTextTemp->get_nodeValue(&varValue);
if(SUCCEEDED(hr))
::MessageBox(NULL, _bstr_t(varValue), _T("Notation Public ID"), MB_OK);
pIXMLDOMTextTemp->Release();
pIXMLDOMTextTemp = NULL;
}
pIXMLDOMText->Release();
pIXMLDOMText = NULL;
}
pIXMLDOMNode->Release();
pIXMLDOMNode = NULL;
break;
}
pIXMLDOMNode->get_firstChild(&pIXMLDOMNodeTemp);
pIXMLDOMNode->Release();
pIXMLDOMNode = pIXMLDOMNodeTemp;
pIXMLDOMNodeTemp = NULL;
}
}
}
catch(...)
{
if(pIXMLDOMNodeTemp)
pIXMLDOMNodeTemp->Release();
if(pIXMLDOMNode)
pIXMLDOMNode->Release();
if(pIXMLDOMTextTemp)
pIXMLDOMTextTemp->Release();
if(pIXMLDOMText)
pIXMLDOMText->Release();
if(pIXMLDOMElement)
pIXMLDOMElement->Release();
DisplayErrorToUser();
}
// Release pIXMLDOMDocument when done with it.