[jdom-interest] Deleting node name:
Grzegorz Kaczor
grzegorz.kaczor at gmail.com
Wed Aug 12 10:16:50 PDT 2009
So where is the problem? Just find the elements you are interested in (for
example via XPath) and just do the same (<declarationsname> is rootEl).
Regards,
G
2009/8/12 ♥..Vishu..♥ <kashiviswanath.sagiri at gmail.com>
> Hi Grzegorz Kaczor,
> Thank you very much for ur concern. But
> the point is my sample xml file is like this:
>
> <DOCUMENT>
> <SECTION>
> <TOPOLOGY>
> <PRNPROC>
> <!-- THIS IS A COMMENT-->
> <declation>
> <declationsname>
> <word>X</word>
> </declationsname>
> </declation>
> <declation>
> <declationname>
> <word>Y</word>
> </declationname>
> </declation>
>
> I would like to remove the <word> tag and replace the contents to
> <declationname> tag.
> Thanking You
>
> Regards
> Kashi V Sagiri
>
> On Wed, Aug 12, 2009 at 4:11 PM, Grzegorz Kaczor <
> grzegorz.kaczor at gmail.com> wrote:
>
>> Hello,
>>
>> Hi,
>>> Could you just brief me how will you do it? and also i have to
>>> remove all the <int> tags from the document. Please reply as early as
>>> possible. Thanking you
>>>
>>
>> For example like that:
>>
>> String xmlString2 = "<input><int><a>aaa</a><b>bbb</b></int></input>";
>>
>> Document doc = new SAXBuilder().build(new StringReader(xmlString2));
>>
>> Element rootEl = doc.getRootElement();
>>
>> Element intEl = rootEl.getChild("int");
>> rootEl.removeContent(intEl);
>> rootEl.addContent(intEl.removeContent());
>>
>> new XMLOutputter().output(doc, System.out);
>>
>> I get:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <input><a>aaa</a><b>bbb</b></input>
>>
>> Regards,
>> Grzegorz
>>
>>
>> --
>> To be a man is, precisely, to be responsible.
>>
>
>
>
> --
> $ VISHU $
>
--
To be a man is, precisely, to be responsible.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20090812/f67ff358/attachment.htm
More information about the jdom-interest
mailing list