Solved

How to add ElementHelper in to another ElementHelper?

Posted on 2009-05-06
12
234 Views
Last Modified: 2012-05-06
I have to create Xml Response.In that i have structure something like  following?

<Element1>
   <ElementHelper1>
            <ElementhelperInside>   </ElementhelperInside>
  </ElementHelper1>
<Element1>

I did  like this:
Element Element1= new Element( "Element1" );

Element Ele1 = new Element( "ElementHelper1", DEFAULTNAMESPACE ) ;
       
     ElementHelper ElementHelper1= new ElementHelper(Ele1 );

Element Ele2 = new Element( "ElementhelperInside", DEFAULTNAMESPACE );
            ElementHelper ElementhelperInside= new ElementHelper(Ele2)
--Here i am adding  elements :But inside helper is not showing containts.

ElementHelper1.addElement(ElementhelperInside.data);
Element1.addContent( ElementHelper1.getData() );

                  
0
Comment
Question by:ANISHKA1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
12 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 24313608
You need to append a child element. What API are you using?
0
 
LVL 92

Expert Comment

by:objects
ID: 24313623
0
 

Author Comment

by:ANISHKA1
ID: 24313630
i am using JDom. Can you please explain me How?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Assisted Solution

by:objects
objects earned 200 total points
ID: 24313689
0
 

Author Comment

by:ANISHKA1
ID: 24313755
I did almost same like which is in link.But i need to add subElement  inside Element which also has sub Elements:-
<MainElement>
   <Element></Element>
   <Element>
      <SubElement>
             <ele1></ele1>
             <ele2></ele2>
    </SubElement>
  </Element>
</MainElement>
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24313926
Try
ElementHelper1.addContent(ElementhelperInside);

Open in new window

0
 
LVL 86

Accepted Solution

by:
CEHJ earned 300 total points
ID: 24313948
So for your last example, you need to call that twice on 'SubElement' for each of its children and once on 'Element' for 'SubElement' itself
0
 

Author Comment

by:ANISHKA1
ID: 24313957
ElementHelper doen't have addContents method.it has only addElement.
0
 

Author Comment

by:ANISHKA1
ID: 24313990
i did this and it added ElementHelperInside into ElementHelper1 but whatever into ElementHelperInside like subElements are missing.
ElementHelper1.addElement(ElementhelperInside);
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24314098
>>ElementHelper doen't have addContents method

http://www.jdom.org/docs/apidocs/org/jdom/Element.html#addContent(org.jdom.Content)

>>but whatever into ElementHelperInside like subElements are missing.

You need to do the same with the sub elements, as i mentioned earlier
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24321106
:-)
0
 
LVL 92

Expert Comment

by:objects
ID: 24321139
glad I could help :)
give me a yell if you need more assistance in the future.

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question