Hi,<br>I am trying to create an XML with following structure.<br> <br><DocRoot><br> <Folder name="xyz"><br> <Folder name="abc"><br> <File>File2</File><br> <File>File3</File><br> </Folder><br> <File>File1</File><br> </Folder><br></DocRoot><br><br>Following is the code snippet of what I have right now.<br><br> //Loop through the list of files & directory to generate XML file<br> private void GenerateXML(String []DirectoryListing) throws IOException{<br> int i=0;<br> File CheckContent;<br>
XMLGenerator.setRootElement(XMLRoot);<br> File CurrentDirectory;<br> for(i=0;i< DirectoryListing.length; i++)<br> {<br> //file/directory<br> String FolderContent = DirectoryListing[i];<br> CheckContent = new File(FolderContent);<br> if (CheckContent.isFile() == true)<br> {<br> Element Folder = new Element("Folder");<br>
CurrentDirectory = new File (FolderContent);<br> Folder.addContent(CurrentDirectory.getParent());<br> Element FileName = new Element("FileName");<br> FileName.addContent(FolderContent);<br> Element FileLength = new
Element("Length");<br> FileLength.addContent(String.valueOf(CheckContent.length()));<br> XMLRoot.addContent(Folder);<br> XMLRoot.addContent(FileName);<br> XMLRoot.addContent(FileLength);<br> }<br><br> if
(CheckContent.isDirectory()==true)<br> {<br> String [] FileList = ReadDirectory(FolderContent);<br> //Element Directory = new Element("SubDirectory");<br> // Directory.addContent(FolderContent);<br> // XMLRoot.addContent(Directory);<br> GenerateXML(FileList);<br> }<br> }<br> }<br><br>I get the following XML from the above
snippet<br><SharedFolder><br> <Folder>Directory</Folder><br> <FileName>text file.txt</FileName><br> <Length>9</Length><br> <Folder>Folder</Folder><br> <FileName>text file2.txt</FileName><br> <Length>9</Length><br></SharedFolder><br><br>My directory is as follows<br>C:\Directory\ text file.txt , Folder\, Folder\text file2.txt.<br><br>Any suggestions?<br><br>thanks<br><br><p> 
<hr size=1>Never miss a thing. <a href="http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs"> Make Yahoo your homepage.</a>