xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: Wolfgang Hoschek <wolfgang.hoschek AT mac.com>
- To: Narjis Malik <narjismalikster AT gmail.com>
- Cc: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] Append in XML file
- Date: Fri, 2 Mar 2007 11:13:23 -0800
If efficiency is not a concern, the XPath approaches outlined by Grzegorz will be easy. A perhaps more syntactically convenient alternative is to use the XQueryUtil.update() method. Both have the same effect.
However, if efficiency in terms of time and space is important, and alternative approach via a streaming NodeFactory is needed, finding the insertion point as the input document streams by, and appending new elements to an output xml stream. I've attached a small program that does the append in such a streaming manner. You might want to adapt it for your purposes.
But if efficiency really matters this is still not good enough because with file based XML, each separate append still has to scan the entire file to find the end, so appending many elements separately will be O(N^2). You'll end up having to consider better alternatives such as a database or B-trees such as embedded JDBM.
Wolfgang.
On Mar 2, 2007, at 1:58 AM, Narjis Malik wrote:
Hello,
I am working on XML files using nux and xPath, I want to append xml
doucument at a particular location, how can I do it....
I will demonstrate my question with the following example
i have a xml document
______________________________________________________________________ _____________
<?xml version="1.0" encoding="UTF-8"?>
<service name="GetFutureSybmolization">
<synonym name="bvcvcvc">
</synonym>
</service>
______________________________________________________________________ _______________
now what i need , i want to append this xml file with new element :
as i scan this xml and when there is service element with name =
"GetFutureSybolization"
then i want to add new element <synonym name="XYZDGD"></synonym>
please help me how can i do it...
as i tried to do it but it append at the end of file but i cant append in
some where else
waiting for a reply
_______________________________________________
XOM-interest mailing list
XOM-interest AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest
-
[XOM-interest] Append in XML file,
Narjis Malik, 03/02/2007
-
Re: [XOM-interest] Append in XML file,
Grzegorz Kaczor, 03/02/2007
-
Message not available
- Re: [XOM-interest] Append in XML file, Grzegorz Kaczor, 03/02/2007
-
Message not available
-
Re: [XOM-interest] Append in XML file,
Grzegorz Kaczor, 03/02/2007
-
Re: [XOM-interest] Append in XML file,
Wolfgang Hoschek, 03/02/2007
- Re: [XOM-interest] Append in XML file, Wolfgang Hoschek, 03/02/2007
Archive powered by MHonArc 2.6.24.