Deleting node name:

View: New views
7 Messages — Rating Filter:   Alert me  

Deleting node name:

by ♥..Vishu..♥ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,
         I want to remove only tagname but not its contents,
for ex:                                  <input>
                                                 <int>1</int>
                                           </input>
from this i wud like to remove only tag name <int> and the ouput has to be like
                                         <input> 1 </input>

                                                                    Thanks in Advance.

Regards
Kashi V Sagiri



--
$  VISHU  $

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

Re: Deleting node name:

by Grzegorz Kaczor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/8/11 ♥..Vishu..♥ <kashiviswanath.sagiri@...>
Hi All,
         I want to remove only tagname but not its contents,
for ex:                                  <input>
                                                 <int>1</int>
                                           </input>
from this i wud like to remove only tag name <int> and the ouput has to be like
                                         <input> 1 </input>


Hello,

I would just detach <int> and attach its contents to <input>.

Regards,
Grzegorz

 


--
$  VISHU  $

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

--
To be a man is, precisely, to be responsible.

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

Re: Deleting node name:

by ♥..Vishu..♥ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
 
Kashi V Sagiri

On Wed, Aug 12, 2009 at 6:50 AM, Grzegorz Kaczor <grzegorz.kaczor@...> wrote:
2009/8/11 ♥..Vishu..♥ <kashiviswanath.sagiri@...>

Hi All,
         I want to remove only tagname but not its contents,
for ex:                                  <input>
                                                 <int>1</int>
                                           </input>
from this i wud like to remove only tag name <int> and the ouput has to be like
                                         <input> 1 </input>


Hello,

I would just detach <int> and attach its contents to <input>.

Regards,
Grzegorz

 


--
$  VISHU  $

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

--
To be a man is, precisely, to be responsible.



--
$  VISHU  $

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

Re: Deleting node name:

by Grzegorz Kaczor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

Re: Deleting node name:

by ♥..Vishu..♥ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...> 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 control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

Re: Deleting node name:

by Grzegorz Kaczor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...>
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@...> 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.

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

RE: Deleting node name:

by Michael Kay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Can't you see, Vishu, that this is exactly equivalent to the problem that Grzegorz solved for you? You pretty well only have to change the element names. You seem to be asking for spoon-feeding here - I can't understand why you still have difficulty, given the information you have been given.
 


From: jdom-interest-bounces@... [mailto:jdom-interest-bounces@...] On Behalf Of ?..Vishu..?
Sent: 12 August 2009 17:40
To: Grzegorz Kaczor
Cc: jdom-interest@...
Subject: Re: [jdom-interest] Deleting node name:

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@...> 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 control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...