Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XML
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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?


Reply With Quote
  #2 (permalink)  
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)
Reply With Quote
  #3 (permalink)  
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:07 PM.


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