I want to do following in a FOR loop i.e. 

1. Get the FOUR elements under <JposEntries> from xml file below.
2. Copy them to some dom4j element(??? Which one to use???)
3. convert that element to string and do some string manipulation
4. Covert that string back to dom4j element
5. Insert that element at the end in <JposEntries>
6. Repeat step 1. (But now the doc will have 8 elements under
<JposEntries>


Thanks,
Devang

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Evan
Kirkconnell
Sent: Monday, March 19, 2007 4:20 PM
To: dom4j-user@lists.sourceforge.net
Subject: Re: [dom4j-user] How to clone multilple Elementsin a Document

Devang,
If the <JposEntries> tag is the element "jPosEntries", then you can do
this:
someOtherElement.content().addAll( ( (Element)jPosEntries.clone() 
).content() );
And all the children of the "jPosEntries" element would be cloned and 
made children of the "someOtherElement" element.

You could also do it iteratively:
for(int i=0; i<jPostEntries.content().size(); i++) someOtherElement.add(

( (Node)jPosEntries.content().get(i) ).clone() );

--Evan

Devang Joshi wrote:
>
> Below is  my xml file. The root is JposEntries and it has 4 elements 
> (JposEntry)
>
> I want to make a clone of 4 elements inside my root element. How do I 
> do that? I know how to make a clone of an element but how to go @ this

> one?
>
>  
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <JposEntries>
>
>    
>
>     <JposEntry logicalName="i6550_form1">
>
>         <prop name="ItemDisplay" type="String" value="item.icg"/>
>
>       </JposEntry>
>
>    
>
>     <JposEntry logicalName="i6550_msr1">
>
>         <prop name="disableMsr" type="Boolean" value="false"/>
>
>       </JposEntry>
>
>    
>
>     <JposEntry logicalName="i6550_pp1">
>
>         <prop name="flowControl" type="String" value="Xon/Xoff"/>
>
>       </JposEntry>
>
>         
>
>     <JposEntry logicalName="i6550_sg1">
>
>         <prop name="flowControl" type="String" value="Xon/Xoff"/>
>
>    </JposEntry>
>
>    
>
> </JposEntries>
>
>  
>
> Thanks,
>
> Devang
>
> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Devang 
> Joshi
> Sent: Tuesday, March 13, 2007 5:07 PM
> To: dom4j-user@lists.sourceforge.net
> Subject: [dom4j-user] How to remove Element from Document
>
>  
>
> I am trying to delete first device element from my xml document.
>
> iterateToDevicePosition() function returns me the first device
element,
>
> But doc.remove() did not work for me. (Note: doc has the parsed xml
>
> file)
>
>  
>
> //Now delete the first device element
>
> Element dummyElem = iterateToDevicePosition();
>
> //Now dummy element has the element I want to remove
>
> doc.remove(dummyElem); //This does not remove it from the doc???
>
>  
>
> Thanks,
>
> Devang
>
>  
>
> -----Original Message-----
>
> From: [EMAIL PROTECTED]
>
> [mailto:[EMAIL PROTECTED] On Behalf Of Evan S.
>
> Kirkconnell
>
> Sent: Tuesday, March 13, 2007 7:52 AM
>
> To: dom4j-user@lists.sourceforge.net
>
> Subject: Re: [dom4j-user] convert String to Element
>
>  
>
> (Element)DocumentHelper.parseText(xml).getRootElement().detach()
>
>  
>
> As a forewarning, I think this creates the element in the null
>
> namespace.  If you need it in the xhtml namespace, you may have to do
a
>
> little more work.
>
> --Evan
>
>  
>
> ----- Original Message -----
>
> From: Devang Joshi <[EMAIL PROTECTED]>
>
> Date: Monday, March 12, 2007 4:44 pm
>
> Subject: [dom4j-user] convert String to Element
>
> To: dom4j-user@lists.sourceforge.net
>
>  
>
> > I am trying to create clone of element then convert the element to
>
> > string. Do some string manipulation and then convert the string
>
> > back to
>
> > element. 
>
> >
>
> > //***This will insert new elements inside the clone***
>
> > Element newElement = (Element) currElement.clone();
>
> >
>
> > //***We need to replace few values in the new element so convert to
>
> > string***
>
> > String strElem = newElement.asXML();
>
> >
>
> > // Do something with string (internal logic)
>
> >
>
> > How do I convert string to element and insert that in my xml
>
> > document?????????????????????????
>
> >
>
> > //this would put the element in the doc
>
> > this.insertElementAt(newElement, this.root.indexOf(currElement)+1);
>
> >
>
> >
>
> >
>
> > Thanks,
>
> >
>
> > Devang
>
> >
>
> > 972-550-2746
>
> >
>
> >
>
> >
>
> >
>
>  
>
>
------------------------------------------------------------------------
>
> -
>
> Take Surveys. Earn Cash. Influence the Future of IT
>
> Join SourceForge.net's Techsay panel and you'll get the chance to
share
>
> your
>
> opinions on IT & business topics through brief surveys-and earn cash
>
>
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE
>
> V
>
> _______________________________________________
>
> dom4j-user mailing list
>
> dom4j-user@lists.sourceforge.net
>
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>
>  
>
>
------------------------------------------------------------------------
-
>
> Take Surveys. Earn Cash. Influence the Future of IT
>
> Join SourceForge.net's Techsay panel and you'll get the chance to 
> share your
>
> opinions on IT & business topics through brief surveys-and earn cash
>
>
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE
V
>
> _______________________________________________
>
> dom4j-user mailing list
>
> dom4j-user@lists.sourceforge.net
>
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>
>
------------------------------------------------------------------------
>
>
------------------------------------------------------------------------
-
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to
share your
> opinions on IT & business topics through brief surveys-and earn cash
>
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE
V
>
------------------------------------------------------------------------
>
> _______________________________________________
> dom4j-user mailing list
> dom4j-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>   


------------------------------------------------------------------------
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE
V
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to