[jdom-interest] creating and parsing files
Bradley S. Huffman
hip at cs.okstate.edu
Sat Jul 12 07:33:36 PDT 2003
Where's your itr.next() call?
Brad
salil khanwalkar writes:
> 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. T
> he 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.
More information about the jdom-interest
mailing list