0

I have a folder full of text files called MainFolder, and I want to convert the folder to an XML representation so that every file in the folder can be edited as a single text file. Would it be possible to generate an XML representation of a folder structure, as shown here, with files inside <file> tags and folders inside folder tags?

<folder name = "MainFolder">
    <file name = "README.txt">
        This is a text file inside a folder called MainFolder. This is the content
        of README.txt.
    </file>
    <folder name = "Java samples">
        <file name = "HelloWorld.java">
            public class HelloWorld{
                public static void main(String[] args){
                    System.out.println("Hello World!");
                }
            }
        </file>
    </folder>
</folder>
Anderson Green
  • 30,230
  • 67
  • 195
  • 328
  • Maybe you could take some inspiration from http://stackoverflow.com/questions/316590/how-do-you-use-cat-recursively – Cyrille Feb 02 '13 at 23:05
  • I tagged this question as "language-agnostic" because I know what I'm trying to accomplish, but I don't know which programming language would be the best fit for the job. – Anderson Green Feb 02 '13 at 23:06
  • The contents would have to be enclosed in a `<![CDATA[` section. But what if one of those files was an XML file and had a `<![CDATA[` section? – Eduardo Feb 02 '13 at 23:10
  • Why would you need this? – Cratylus Feb 02 '13 at 23:14
  • @Cratylus I want to create and edit multiple text files at once using a single text file, since it's easier than opening multiple windows and constantly switching back and forth between them. – Anderson Green Feb 02 '13 at 23:17

1 Answers1

0

Try this utility:

http://code.google.com/p/xml-dir-listing/

(padded because Stackoverflow doesn't like short answers)

Michael Kay
  • 156,231
  • 11
  • 92
  • 164