[jdom-interest] creating and parsing files

salil khanwalkar k_salil at yahoo.com
Sat Jul 12 06:35:56 PDT 2003


Hi,
My xml file  looks like this --
<?xml version="1.0" encoding="UTF-8"?>
<DataSet>
 <Username>qqlil</Username>
 <Password>welil1980</Password>
 <Username>iotin</Username>
 <Password>cvbtin1975</Password>
</DataSet >
i copy the contents in a list and then iterate through it using a iterator. The while(),
 loops infinitely and prints only the first element qqlil welil1980. I am not able to get the 
second username and password.  Is my xml file structure wrong or the code for reading
it is wrong?
// part  of the code
      SAXBuilder builder = new SAXBuilder();
      Document doc = builder.build(input);
      Element root = doc.getRootElement();
      List dataset = doc.getContent();
     // System.out.println(dataset);
      
      Iterator itr = dataset.iterator();      
      StringBuffer full = new StringBuffer();
      while(itr.hasNext()) {
          full.append(root.getChildText("Username") + " ");
          full.append(root.getChildText("Password") + " ");
          System.out.println(full.toString());          
      }
Thank You,
Salil.



---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20030712/189d91c6/attachment.htm


More information about the jdom-interest mailing list