What exactly were the performance problems which you encountered?
And what exactly are you looking for alternatives to? Do you want to scrap the idea of using a DOM and rewriting the application to handle the XML some other way? Or were you just looking for some other way to import data into an existing DOM?
The problem is that I have a DOM tree into which I want to copy XML from a file. That XML content is huge in the number of nodes and their levels.
Loading it into a DOM node and using importNode will be expensive in my case, and I was just trying to see if I can copy that entire thing just as a String into my DOM tree.
My XML is without a schema and all I want is to add huge XML to existing DOM tree without importNode that will parse that content (and therefore consume time).
Why are you using DOM at all, why not treat the problem as one of merging two text streams?
If you absolutely need to parse document 1 to find the insertion point, do it with SAX, writing the contents of all events as Strings to a new output file and inserting your new text when you hit the insertion point.
aswin pal wrote:Also, would passing xml to createTextNode() as a normal string be a bad idea? I have not tried it at the moment...
It would be a bad idea if you expected the createTextNode method to parse the XML into nodes. It would be a good idea if you wanted the XML to remain as an uninterpreted string, and if you expected the markup (characters like < and >) to be escaped.
A wop bop a lu bob a womp bam boom. Tutti frutti ad:
a bit of art, as a gift, the permaculture playing cards