Solved

How to add ElementHelper in to another ElementHelper?

Posted on 2009-05-06
12
225 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
 
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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

856 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