本文整理汇总了C++中DOM_Node::cloneNode方法的典型用法代码示例。如果您正苦于以下问题:C++ DOM_Node::cloneNode方法的具体用法?C++ DOM_Node::cloneNode怎么用?C++ DOM_Node::cloneNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOM_Node
的用法示例。
在下文中一共展示了DOM_Node::cloneNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: traverseTextNode
/**
* Utility method for traversing a text node that we know
* a-priori to be on a left or right boundary of the range.
* This method does not properly handle text nodes that contain
* both the start and end points of the range.
*
*/
DOM_Node RangeImpl::traverseTextNode( DOM_Node n, bool isLeft, int how )
{
DOMString txtValue = n.getNodeValue();
DOMString newNodeValue;
DOMString oldNodeValue;
if ( isLeft )
{
int offset = getStartOffset();
newNodeValue = txtValue.substringData( offset , fStartContainer.getNodeValue().length()-offset);
oldNodeValue = txtValue.substringData( 0, offset );
}
else
{
int offset = getEndOffset();
newNodeValue = txtValue.substringData( 0, offset );
oldNodeValue = txtValue.substringData( offset , fEndContainer.getNodeValue().length()-offset );
}
if ( how != CLONE_CONTENTS )
n.setNodeValue( oldNodeValue );
if ( how==DELETE_CONTENTS )
return null;
DOM_Node newNode = n.cloneNode( false );
newNode.setNodeValue( newNodeValue );
return newNode;
}
示例2: traversePartiallySelected
/**
* Utility method for traversing a single node when
* we know a-priori that the node if partially
* selected and is not a text node.
*
*/
DOM_Node RangeImpl::traversePartiallySelected( DOM_Node n, int how )
{
switch( how )
{
case DELETE_CONTENTS:
return null;
case CLONE_CONTENTS:
case EXTRACT_CONTENTS:
return n.cloneNode( false );
}
return null;
}
示例3: traverseFullySelected
/**
* Utility method for traversing a single node when
* we know a-priori that the node if fully
* selected.
*
*/
DOM_Node RangeImpl::traverseFullySelected( DOM_Node n, int how )
{
switch( how )
{
case CLONE_CONTENTS:
return n.cloneNode( true );
case EXTRACT_CONTENTS:
if ( n.getNodeType()== DOM_Node::DOCUMENT_TYPE_NODE )
{
throw DOM_DOMException(
DOM_DOMException::HIERARCHY_REQUEST_ERR, null);
}
return n;
case DELETE_CONTENTS:
n.getParentNode().removeChild(n);
return null;
}
return null;
}