Solved

How to add ElementHelper in to another ElementHelper?

Posted on 2009-05-06
12
199 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
  • 5
  • 4
  • 3
12 Comments
 
LVL 86

Expert Comment

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

Expert Comment

by:objects
Comment Utility
0
 

Author Comment

by:ANISHKA1
Comment Utility
i am using JDom. Can you please explain me How?
0
 
LVL 92

Assisted Solution

by:objects
objects earned 200 total points
Comment Utility
0
 

Author Comment

by:ANISHKA1
Comment Utility
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
Comment Utility
Try
ElementHelper1.addContent(ElementhelperInside);

Open in new window

0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 86

Accepted Solution

by:
CEHJ earned 300 total points
Comment Utility
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
Comment Utility
ElementHelper doen't have addContents method.it has only addElement.
0
 

Author Comment

by:ANISHKA1
Comment Utility
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
Comment Utility
>>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
Comment Utility
:-)
0
 
LVL 92

Expert Comment

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

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
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.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now