[jdom-interest] Iterating through XML

Laurent Bihanic laurent.bihanic at atosorigin.com
Tue Jul 6 05:17:45 PDT 2004


for (Iterator i=doc.getRootElement().getChildren("InboundMessage").iterator(); 
i.hasNext(); )
{
     Element inboundMessage = (Element)(i.next());

     ...
}

Laurent


Edd Dawson wrote:

> Hi 
> 
> I have got the following code :
> 
> Document doc = null;
> try {
> 	doc = builder.build(reader);
> } catch(Exception ex) {
> 	return "Error on making xml returned SAXable" + ex.getMessage();
> 		}
> 
> 
> 
> Which puts my inputStream XML nicely into the parser.
> 
> 
> Now i have the following in there :
> 
> <Response>
>    <InboundMessage>
>       <Ticket>1278</Ticket>
>       <MessageText>Example 1</MessageText>
>       <Phone>+4409878656787</Phone>
>       <Date>123456123</Date>
>    </InboundMessage>
>    <InboundMessage>
>       <Ticket>1279</Ticket>
>       <MessageText>Example 2</MessageText>
>       <Phone>+4409878656787</Phone>
>       <Date>123456123</Date>
>    </InboundMessage>
>    <InboundMessage>
>       <Ticket>1280</Ticket>
>       <MessageText>Example 3</MessageText>
>       <Phone>+4409878656787</Phone>
>       <Date>123456123</Date>
>    </InboundMessage>
> </Request>
> 
> 
> 
> I can't figure out from the manuals and docs that i have read how to
> iterate through all the instances of <InboundMessage> so i can retrieve
> the elements of each and bung them in a database.
> 
> Would anyone have any ideas how to do so?
> 
> thanks
> Edd
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
> 

-- 
                  wWw
                 (o o)
-------------ooO-(_)-Ooo-----------------------------------------------
Laurent Bihanic                | Tel: +33 (0)1 55.91.21.93 (direct)
AtosOrigin Systems Integration |      +33 (0)1 55.91.20.00
Generic Solutions / SC         | Fax: +33 (0)1 55.91.22.31
Les Miroirs - Bat. C           |
18, avenue d'Alsace            |
F-92926 La Defense Cedex       | E-mail: laurent.bihanic at atosorigin.com
-----------------------------------------------------------------------

Plonge tes racines dans la terre
Laisse nous vivre avec le vent
Passe l'hiver comme les graines
Et chante au printemps comme les oiseaux


DISCLAIMER:
The opinions expressed are entirely my own and may not necessarily be
those of my employer.  Also, I am not now nor have I ever been a
lawyer.  My opinions are provided as-is with absolutely no warrantee of
merchantability or fitness for any particular use.  Besides, you can't
prove I typed this.  No body saw me type this.  Who says I typed this?



More information about the jdom-interest mailing list