<DIV>Hi</DIV>
<DIV>I have 2 questions-</DIV>
<DIV>1.</DIV>
<DIV>I want to generate a dataset which will contain First name,Middle name And Last name</DIV>
<DIV>I want to group them accordingly.</DIV>
<DIV>My file should like this-</DIV>
<DIV><DataSet></DIV>
<DIV> <First></DIV>
<DIV> "First names should come here"</DIV>
<DIV> </First></DIV>
<DIV> </DIV>
<DIV>
<DIV> <Middle></DIV>
<DIV> "<Middle names should come here"</DIV>
<DIV> </Middle></DIV>
<DIV> </DIV>
<DIV>
<DIV> <Last></DIV>
<DIV> "Last names should come here"</DIV>
<DIV> </Last></DIV></DIV></DIV>
<DIV> </DIV>
<DIV></DataSet</DIV>
<DIV> </DIV>
<DIV>Here is my code for the same-- (not getting expected results)</DIV>
<DIV> </DIV>
<DIV> Element DSElement = new Element("DataSet");<BR> Document doc = new Document(DSElement);<BR> DocType type = new DocType("html", "-//W3C//DTD XHTML 1.0 Transitional//EN", <BR> "<A href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</A>");<BR> </DIV>
<DIV> Element FElement = new Element("First");<BR> FElement.addContent(new Element("F1").addContent("aaa"));<BR> FElement.addContent(new Element("F2").addContent("sss"));</DIV>
<DIV> Element MElement = new Element("Middle");<BR> FElement.addContent(new Element("P1").addContent("ddd"));<BR> FElement.addContent(new Element("P2").addContent("qqq"));<BR> <BR> XMLOutputter outputter = new XMLOutputter(" ", true); <BR> FileWriter writer = new FileWriter("dataset.xml");<BR> outputter.output(doc, writer);<BR> writer.close();<BR></DIV>
<DIV>2-</DIV>
<DIV> </DIV>
<DIV>To read a file i copy its contents in a List object.</DIV>
<DIV>Then i use an Iterator object to iterate through the list.</DIV>
<DIV> </DIV>
<DIV>while(iterator.hasNext()){</DIV>
<DIV> doc.getRootElement.getChildText("First");///here instead of specifying the "First" string i want to iterate through the list and retreive their values</DIV>
<DIV>I tried get(i) in a for loop but no results</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>This returns me the value of the child. The problem is that i keep on getting the same value for all child nodes, instead of the value of the next </DIV>
<DIV>child node.</DIV>
<DIV> </DIV>
<DIV>Somebody please help me out.</DIV>
<DIV> </DIV>
<DIV>Thank you,</DIV>
<DIV>Salil.</DIV>
<DIV> </DIV>
<DIV> </DIV><p><hr SIZE=1>
Do you Yahoo!?<br>
Free <a href="http://us.rd.yahoo.com/mail_us/tag/*http://calendar.yahoo.com">online calendar</a> with sync to Outlook(TM).