Do you have a very large number of top-level elements in the DOM?  I am not 
offering an expert opinion, but it seems that if Xerces had to linearly scan 
many elements that would take a while.

-----Original Message-----
From: mini thomas [mailto:[email protected]] 
Sent: Monday, August 24, 2009 6:36 AM
To: [email protected]
Subject: XPath (xerces 3.0.1) - accessing non existing node - performance issues

Hi,
 
I am using xerces 3.0.1 and evaluating an XPath expression "a/b/c".
             DOMNode* GetNode(DOMNode* startingNode , XMLCh* xpathStr)
            {
                         DOMDocument *doc =  m_pParser->getDocument();
                         DOMXPathResult* result=doc->evaluate(
                      xpathStr,
                      startingNode,
                      NULL,
                      DOMXPathResult::FIRST_ORDERED_NODE_TYPE,
                      NULL);
                        if(result)
                        {
                                    DOMNode* tt =   result->getNodeValue();
                                    result->release();
                                return tt;
                        }
                        else
                                    return NULL; 
            }
 
 
The time taken by GetNode is approximately 0 milliseconds when path a/b/c 
exists in the document.
But the time taken is 40 milliseconds when path a/b/c doesn't exist.
 
Please explain this behavior. Is there any way to reduce the time taken for 
XPath evaluation when the node doesn't exist?
 
Thanks
Mini
 
 


      

Reply via email to