当前位置: 首页>>代码示例>>C++>>正文


C++ DOM_Node::setNodeValue方法代码示例

本文整理汇总了C++中DOM_Node::setNodeValue方法的典型用法代码示例。如果您正苦于以下问题:C++ DOM_Node::setNodeValue方法的具体用法?C++ DOM_Node::setNodeValue怎么用?C++ DOM_Node::setNodeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DOM_Node的用法示例。


在下文中一共展示了DOM_Node::setNodeValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:mydw,项目名称:mydw,代码行数:34,代码来源:RangeImpl.cpp

示例2: traverseSameContainer

/**
 * Visits the nodes selected by this range when we know
 * a-priori that the start and end containers are the same.
 *
 */
DOM_DocumentFragment RangeImpl::traverseSameContainer( int how )
{
    DOM_DocumentFragment frag = null;
    if ( how!=DELETE_CONTENTS)
        frag = fDocument.createDocumentFragment();

    // If selection is empty, just return the fragment
    if ( fStartOffset==fEndOffset )
        return frag;

    DOM_Node current = fStartContainer;
    DOM_Node cloneCurrent = null;

    // Text node needs special case handling
    if ( fStartContainer.getNodeType()== DOM_Node::TEXT_NODE )
    {
        cloneCurrent = fStartContainer.cloneNode(false);
        cloneCurrent.setNodeValue(
            cloneCurrent.getNodeValue().substringData(fStartOffset, fEndOffset - fStartOffset));

        // set the original text node to its new value
        if ( how != CLONE_CONTENTS )
            ((DOM_Text &)fStartContainer).deleteData(fStartOffset, fEndOffset-fStartOffset);
        if ( how != DELETE_CONTENTS)
            frag.appendChild(cloneCurrent);
    }
    else {
        // Copy nodes between the start/end offsets.
        DOM_Node n = getSelectedNode( fStartContainer, fStartOffset );
        int cnt = fEndOffset - fStartOffset;
        while( cnt > 0 )
        {
            DOM_Node sibling = n.getNextSibling();
            DOM_Node xferNode = traverseFullySelected( n, how );
            if ( frag!=null )
                frag.appendChild( xferNode );
            --cnt;
            n = sibling;
        }
    }

    // Nothing is partially selected, so collapse to start point
    if ( how != CLONE_CONTENTS )
        collapse(true);
    return frag;
}
开发者ID:mydw,项目名称:mydw,代码行数:51,代码来源:RangeImpl.cpp


注:本文中的DOM_Node::setNodeValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。