Hi All,                          
 What is the best way to convert a NodeRefList
> to DOM_NodeList. Tried using a vector of DOM_Nodes
> to return. However, the destructor of the
> std::vector
> crashes. Any tips/pointers would be appreciated.
> 
> Here is the code:
bool CimfXMLReader::selectNodes(const TCHAR*
xpathExpr, std::vector<DOM_Node>& nodes)
{
        // Set up a XercesParserLiaison and use it to wrap
the DOM_Document
        // in a XalanDocument.
        XercesDOMSupport   theDOMSupport;
        XercesParserLiaison     theParserLiaison(theDOMSupport);

theParserLiaison.setDoNamespaces(m_parser->getDoNamespaces());
        XalanDocument* theDoc =
theParserLiaison.createDocument(getDocument());

        assert(theDoc);

        XPathEvaluator  theEvaluator;

        // OK, let's find the context node...
        NodeRefList const       theContextNodes =
                theEvaluator.selectNodeList(
                theDOMSupport,theDoc,
                XalanDOMString(xpathExpr).c_str(),
                theDoc->getDocumentElement());

        nodes.clear();  
        int numNodes = theContextNodes.getLength();
        if(numNodes)
        {
                nodes.reserve(numNodes);
                const XercesDocumentBridge* bridge=
theParserLiaison.mapDocument(theDoc);
                if(bridge)
                {
                        for(int i=0;i<numNodes;++i)
                        {
                                DOM_Node aNode =
bridge->mapNode(theContextNodes.item(i));                                       
                        
                                nodes.push_back(aNode.cloneNode(false));
                        }
                        return true;
                }
        }                       
        return false;
}

=====


__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

Reply via email to