Re: Removing an XML element
Alexander Mischur <[email protected]> Wed, 18 Aug 2010 09:04:58 +0200
| Newsgroups | gmane.text.xml.xmlbeans.user |
|---|---|
| Message-ID | <[email protected]> |
It works fine for me. maybe you can give some more informations. I attached a simple example for eclipse. Note: At first run build.xml with an Ant [define folder of your xmlbeans-libs in build.xml] then open project in eclipe [define variable for xmlbeans-libs] -Alex On Tue, Aug 17, 2010 at 9:30 PM, Duane Zamrok <[email protected]> wrote: > Did the code execute without issue and just not work, or did it throw an > exception of some sort? > > I've never really tried removing an element from my XMLObject hierarchy, > but when I add elements I do the exact same kind of thing. Perhaps you could > try something like the following. (fair warning this code is off the hip and > not optimized or tested) > > Text[] newArray = body.getParagraphArray(0).getTextArray(); > for(int index =1; index < newArray.length - 1; index++) > newArray[index] = newArray[index + 1]; > body.getParagraphArray(0).setTextArray(newArray); > > > -Duane > > > -----Original Message----- > From: minimalism [mailto:[email protected]] > Sent: Friday, August 13, 2010 5:29 PM > To: [email protected] > Subject: Removing an XML element > > > I searched the forums for a solution to the problem I am having, but I > could > not find anything that would work for me. I have an xml file that has > nested > elements. A very simplified example would be: > <code><pre> > <body> > <paragraph font="Verdana"> > <text size = "2">Line1</text> > <text size = "1">Line2</text> > <text>Line3</text> > </paragraph> > </body> > </pre></code> > > I want to remove line 2 above. I do this: > > <code><pre> > body.getParagraphArray(0).removeText(1); > </pre></code> > > This did not work. Am I missing something? > > Thanks for your help in advance. > -- > View this message in context: > http://old.nabble.com/Removing-an-XML-element-tp29433197p29433197.html > Sent from the Xml Beans - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
RemovingElementWithXmlBeans.zip
(application/zip, 45.8 KB) - not displayed