Note that there are some explanatory texts on larger screens.

plurals
  1. POcreating xdocument structure
    primarykey
    data
    text
    <p>I am trying to index a drive to a xml file. My pitiful attempt is this:</p> <pre><code> internal static void createIndex(String path, String driveLabel) { XDocument w = new XDocument(); w.Add(createStructure(path, new XElement("root"))); w.Save(driveLabel +".xml"); } internal static XElement createStructure(String path, XElement x) { try { String[] files = Directory.GetFiles(path); String[] folders = Directory.GetDirectories(path); foreach (String s in folders) { x.Add("directory", createStructure(s, x)); } foreach (String f in files) { x.Add(new XElement("file", f)); } } catch (Exception e) { } return x; } </code></pre> <p>some output here - simple file structure - root has 2 mp3s and 1 folder containing the 2 files.</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;root&gt; &lt;file&gt;E:\.wd_tv\ph.db&lt;/file&gt; &lt;file&gt;E:\.wd_tv\ph.db-journal&lt;/file&gt;directory&lt;root&gt; &lt;file&gt;E:\.wd_tv\ph.db&lt;/file&gt; &lt;file&gt;E:\.wd_tv\ph.db-journal&lt;/file&gt;directory&lt;/root&gt; &lt;file&gt;E:\180.mp3&lt;/file&gt; &lt;file&gt;E:\181.mp3&lt;/file&gt; &lt;/root&gt; </code></pre> <p>I am getting some strangely intermixed tags there and I simply don't get it. Any help appreciated.</p> <p><em>using od's loop structure it changes to that:</em></p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;root&gt;directory&lt;root&gt;directory&lt;/root&gt; &lt;file&gt;E:\180.mp3&lt;/file&gt; &lt;file&gt;E:\181.mp3&lt;/file&gt; &lt;/root&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload