<!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 &quot;nicer&quot;), 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 &quot;/descendant::InboundMessage&quot;). 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 &quot;Error on making xml returned SAXable&quot; + ex.getMessage();
                }



Which puts my inputStream XML nicely into the parser.


Now i have the following in there :

&lt;Response&gt;
   &lt;InboundMessage&gt;
      &lt;Ticket&gt;1278&lt;/Ticket&gt;
      &lt;MessageText&gt;Example 1&lt;/MessageText&gt;
      &lt;Phone&gt;+4409878656787&lt;/Phone&gt;
      &lt;Date&gt;123456123&lt;/Date&gt;
   &lt;/InboundMessage&gt;
   &lt;InboundMessage&gt;
      &lt;Ticket&gt;1279&lt;/Ticket&gt;
      &lt;MessageText&gt;Example 2&lt;/MessageText&gt;
      &lt;Phone&gt;+4409878656787&lt;/Phone&gt;
      &lt;Date&gt;123456123&lt;/Date&gt;
   &lt;/InboundMessage&gt;
   &lt;InboundMessage&gt;
      &lt;Ticket&gt;1280&lt;/Ticket&gt;
      &lt;MessageText&gt;Example 3&lt;/MessageText&gt;
      &lt;Phone&gt;+4409878656787&lt;/Phone&gt;
      &lt;Date&gt;123456123&lt;/Date&gt;
   &lt;/InboundMessage&gt;
&lt;/Request&gt;



I can't figure out from the manuals and docs that i have read how to
iterate through all the instances of &lt;InboundMessage&gt; 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 &lt;<A HREF="mailto:phil.weighill-smith@volantis.com"><U>phil.weighill-smith@volantis.com</U></A>&gt;<BR>
Volantis Systems
</TD>
</TR>
</TABLE>
</PRE>
</BODY>
</HTML>