On 5/18/2010 5:28 PM, Helzer, Mark wrote:
Hi all,
Documentation and the list archive say that you can use a Xerces DOM document
if you wish to update your document while using XPath. Or at least something
similar, perhaps I'm misconstruing the intent.
Here is what I would like to do:
I have an existing app using Xerces DOM where I create/update an XML document.
Looping through a cvs file, extracting the data and updating or adding elements
in the XML as needed. This was working fine until the data and the # of
elements were smaller. After adding new types of data performance has gone in
the hopper.
I would like to be able to use XPath to locate nodes for update, if the node
is not found I would add the new element and refresh the document tree.
Perhaps this is not how XPath is intended to be used?
Unfortunately, you haven't provide nearly enough specific information to
answer your question.
In general, Xalan-C's wrapper around the Xerces-C DOM is not that
efficient for modifying a document. In particular, it's a requirement
you rebuild the wrapper when you make modifications, so it would be
better if you evaluated all of the XPath expressions at once, then made
all of the modifications.
If you could post some code snippets, and be more specific about exactly
what changes are causing the performance problem, that would be helpful.
Also, this is exactly the kind of manipulation that XSLT was designed to
do, so you might consider writing a stylesheet to do this transformation.
Dave