[jdom-interest] getChildren
Andres March
andres at ehealthcontracts.com
Tue Dec 17 16:33:58 PST 2002
Don't know if this is any better but:
List watchers = new ArrayList(instance.getChildren("watcher"));
watchers.add(newwatcher);
instance.removeChildren("watcher");
List children = new ArrayList(instance.getChildren());
instance.removeChildren();
children.addAll(0,watchers);
instance.setChildren(children);
ANDRES MARCH
LEAD APPLICATION DEVELOPER
eHEALTHCONTRACTS, INC.
WWW.eHEALTHCONTRACTS.COM <http://www.eHEALTHCONTRACTS.COM>
OFFICE: 510.581.5646 x205
MOBILE: 415.999.6735
FAX: 510.582.8013
Note:
The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer.
Thank you. eHealthContracts, Inc.
-----Original Message-----
From: ted.erickson at usbank.com [mailto:ted.erickson at usbank.com]
Sent: Friday, December 13, 2002 6:41 AM
To: jdom-interest at jdom.org
Subject: Re: [jdom-interest] getChildren
Hopefully someone has a better answer to this problem.
The problem:
Grab all children named "watcher" from a list
Append a new child to the list of watchers
The new child appears at the end of the original list instead of at the end
of the watchers list
The solution:
1- get the list of "tupleID"
2- remove the children named "tupleID"
3- add the new "watcher" node
4- walk through the list of "tupleID" and add each node to the list
Does anyone have a more elegant or intuitive solution?
Ted Erickson
-------------------------
Yes, but i would that the new added watcher will be at the end of the list
of the watcher and not at the end of the element tupleID, because i have a
sequence in the xsd schema associated and so the order must be respect!!!!
How can relize it?
<instance>
<watcher>a</watcher>
<watcher>b</watcher>
<watcher>c</watcher>
<tupleID>1</tupleID>
<tupleID>3</tupleID>
</instance>
MANY THANKS
---------------------------------------------------------------------------------------------------------
Yanked incorrect reply ...
---------------------------------------------------------------------------------------------------------
i have an element accesslist with inside a sequence of instance
element.Each instance consist on 2 different element named watcher and
tupleid.
<instance>
<watcher>a</watcher>
<watcher>b</watcher>
<tupleID>1</tupleID>
<tupleID>3</tupleID>
</instance>
My desire is to add a new element watcher. So i do:
List watchers = instance.getChildren("watcher");
Element newatcher = new Element("watcher");
newatcher.setText("c");
watchers.add(newatcher);
but i get:
<instance>
<watcher>a</watcher>
<watcher>b</watcher>
<tupleID>1</tupleID>
<tupleID>3</tupleID>
<watcher>c</watcher>
</instance>
that it's wrong!!!Where i do the mistake?
BRGS
Antonello
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
More information about the jdom-interest
mailing list