Hi Kelly,
given your requirements, have you tried using the
createNodeIterator/createTreeWalker APIs exposed by DOMDocument?
Alberto
Il 25/10/2012 16:12, Kelly Davis ha scritto:
In our code we have many loops of the form....
XMLCh *namespace = ...
XMLCh *elementName = ...
DOMNodeList *domNodeList = domElement->getElementsByTagNameNS(namespace,
elementName);
XMLSize_t domNodeListSize = domNodeList->getLength();
for (XMLSize_t count = 0; count < domNodeListSize; ++count) {
DOMElement *nextDOMElement = (DOMElement *) domNodeList->item(count);
// Modify nextDOMElement by adding attributes
}
These are extremely slow.
The problem seems to be multi-fold:
1. The API has no getElementsByTagNameNS() that returns a "const DOMNodeList*",
thus allowing optimizations. (Not xerces-c's fault, but it's a nice-to-have!)
2. DOMNodeList:: getLength() is order O(V + E), where V is the number of
DOMElements under domElement and E is the number of edges
3. DOMNodeList:: item(XMLSize_t index) is of oder O(V + E) as nextDOMElement's
attributes are modified and thus the DOMDocument's fChanges is incremented
These yield a for loop that is of O((V + E)^2), which for the number of such
loops we have is far, far to slow.
Short of re-writing DOMDeepNodeListImpl, what is the proper solution to this
problem?
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]