Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to add ElementHelper in to another ElementHelper?

Posted on 2009-05-06
12
Medium Priority
?
292 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
ID: 24313608
You need to append a child element. What API are you using?
0
 

Author Comment

by:ANISHKA1
ID: 24313630
i am using JDom. Can you please explain me How?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 92

Assisted Solution

by:objects
objects earned 800 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 1200 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

876 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