Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
| Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 10th, 2006, 11:35 AM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Directory structure to XML.

A windows folder structure has to be represented in an xml through a java program. For ex if the folder structure is:
a
|-b
|-1.html
,
the output should be
<a>
<file>1.html</file>
<b>
</b>
</a>
Any approach you would recommend?


 
Old January 15th, 2006, 12:19 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

A recursive loop throughthe file system creating a node for each foldr or file.
You will find the resulting XML much easier to work with if it something like:
Code:
<fileSystem>
  <drive name="c:">
    <item type="folder" name="folder1">
      <item type="file" name="file1"/>
      <item type="file" name="file2"/>
      <item type="folder" name="folder2"/>
      <item type="folder" name="folder3">
        <item type="file" name="file3"/>
      </item>
    </item>
  </drive>
</fileSystem>
This will be much easier to search than the example you showed.
You may also want to store the path to each item as an attribute, depending on how you intend to use the results.


--

Joe (Microsoft MVP - XML)
 
Old March 8th, 2013, 04:55 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default another way to represent the directory structure.

i need to create a folders structure for an installer project, i have been thinking and i told the better way is as follows:

Code:
<root>
   <folder name = "Folder1 (level 1)">
      <folder name = "Folder2 (level 2)"></folder>
   </folder>
   <folder name = "Folder3 (level 1)">
   </folder>
</root>
this way it is possible to represent the structure hierarchically.
what do you think? is there a better way? i'll appreciate any help.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding HTTP Directory structure attacks... ashokparchuri C# 1 January 28th, 2008 10:06 AM
pick data from xml structure crmpicco XML 2 December 1st, 2006 11:01 AM
backslash in XML structure crmpicco Classic ASP Basics 0 May 3rd, 2005 06:45 AM
Adding directory structure to a listbox EddyT Excel VBA 0 March 7th, 2005 06:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.