<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7036.0">
<TITLE>Default namespaces</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT COLOR="#000000" SIZE=2 FACE="Arial">Hi,</FONT>
<BR><FONT COLOR="#000000" SIZE=2 FACE="Arial">I am not understanding how to use default namespaces with JDOM. Seeing strange behavior. Here is a sample XML:</FONT>
</P>
<P><FONT COLOR="#000000" SIZE=2 FACE="Arial"><litleResponse version="4.1" xmlns="<A HREF="http://www.litle.com/schema">http://www.litle.com/schema</A>" response="0" message="Valid Format" litleSessionId="2734282201"></FONT></P>
<P> <FONT COLOR="#000000" SIZE=2 FACE="Arial"><batchResponse id="20081216211506" litleBatchId="2734282300" merchantId="044700"></FONT>
<BR> <FONT COLOR="#000000" SIZE=2 FACE="Arial"><authorizationResponse reportGroup="BWB" customerId="88673"></FONT>
<BR> <FONT COLOR="#000000" SIZE=2 FACE="Arial"><litleTxnId>271178391204</litleTxnId></FONT>
<BR> <FONT COLOR="#000000" SIZE=2 FACE="Arial"><orderId>20081216-2115-88673</orderId></FONT>
<BR> <FONT COLOR="#000000" SIZE=2 FACE="Arial"><response>000</response></FONT>
<BR> <FONT COLOR="#000000" SIZE=2 FACE="Arial"><responseTime>2008-12-17T04:15:06</responseTime></FONT>
<BR> <FONT COLOR="#000000" SIZE=2 FACE="Arial"><message>Approved</message></FONT>
<BR> <FONT COLOR="#000000" SIZE=2 FACE="Arial"><authCode>11111</authCode></FONT>
<BR> <FONT COLOR="#000000" SIZE=2 FACE="Arial"><fraudResult></FONT>
<BR> <FONT COLOR="#000000" SIZE=2 FACE="Arial"><avsResult>01</avsResult></FONT>
<BR> <FONT COLOR="#000000" SIZE=2 FACE="Arial"></fraudResult></FONT>
<BR> <FONT COLOR="#000000" SIZE=2 FACE="Arial"></authorizationResponse></FONT>
<BR> <FONT COLOR="#000000" SIZE=2 FACE="Arial"></batchResponse></FONT>
<BR><FONT COLOR="#000000" SIZE=2 FACE="Arial"></litleResponse></FONT>
</P>
<P><FONT COLOR="#000000" SIZE=2 FACE="Arial">And here is some java code that loads it:</FONT>
</P>
<P><FONT COLOR="#000000" SIZE=2 FACE="Arial">SAXBuilder builder = new SAXBuilder();</FONT>
<BR><FONT COLOR="#000000" SIZE=2 FACE="Arial">File inFile = new File("some-file.xml");</FONT>
<BR><FONT COLOR="#000000" SIZE=2 FACE="Arial">Document xmlResponseDoc = builder.build(inFile);</FONT>
<BR><FONT COLOR="#000000" SIZE=2 FACE="Arial">Element rootResponseElem = xmlResponseDoc.getRootElement();</FONT>
</P>
<P><FONT COLOR="#000000" SIZE=2 FACE="Arial">Now, after loading this document, I can read the attributes of the <litleResponse> element just fine using rootResponseElem.getAttributeValue(). However, if I try to get the <batchResponse> element using the code below, null is returned:</FONT></P>
<P><FONT COLOR="#000000" SIZE=2 FACE="Arial">Element elem = rootResponseElem.getChild("batchResponse");</FONT>
</P>
<P><FONT COLOR="#000000" SIZE=2 FACE="Arial">I think it has something to do with the xmlns="<A HREF="http://www.litle.com/schema">http://www.litle.com/schema</A>" attribute because I had trouble with it as part of the request as well.</FONT></P>
<P><FONT COLOR="#000000" SIZE=2 FACE="Arial">What is the "best practice" for handling default namespaces in JDOM as specified in the above xml example?</FONT>
</P>
<P><FONT COLOR="#000000" SIZE=2 FACE="Arial">Thanks,</FONT>
</P>
<P><FONT COLOR="#000000" SIZE=2 FACE="Arial">Brian Barnett</FONT>
</P>
</BODY>
</HTML>