<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.0.10">
</HEAD>
<BODY>
You can get the children of the Response element (your document root) and iterate that list assuming your response only has inbound messages in it (or you can apply an element filter to select only the inbound message children). Alternatively (and perhaps "nicer"), you could use an XPath to locate your inbound messages and iterate over the set of nodes returned; this way you can handle the situation where a response can contain other data too, or where you re-structure the response to have additional layers within it, without the need to change your code (assuming you use an appropriate XPath such as "/descendant::InboundMessage"). See <A HREF="http://www.w3.org/TR/xpath">http://www.w3.org/TR/xpath</A> for a description of XPath.<BR>
<BR>
JDOM has an integration with the jaxen XPath processor (which is a very nice piece of technology).<BR>
<BR>
Phil :n)<BR>
<BR>
On Tue, 2004-07-06 at 12:34, Edd Dawson wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE><FONT COLOR="#737373"><I>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:</FONT>
<A HREF="http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com"><U>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com</U></I></A></PRE>
</BLOCKQUOTE>
<PRE><TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
-- <BR>
Phil Weighill-Smith <<A HREF="mailto:phil.weighill-smith@volantis.com"><U>phil.weighill-smith@volantis.com</U></A>><BR>
Volantis Systems
</TD>
</TR>
</TABLE>
</PRE>
</BODY>
</HTML>