Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The following perl code will do the trick (maybe minus the XML file indentation):</p> <pre><code>package FilesToXml; use IO; use File::Find; use XML::Writer; use vars qw(@ISA @EXPORT @EXPORT_OK); require Exporter; @ISA = qw(Exporter); @EXPORT = qw(SetRequestedType GenerateXml); my $group_name = ""; my $file_type = ""; my $ext = ""; my $writer = ""; sub SetRequestedType { $group_name = shift; $file_type = shift; $ext = shift; } sub wanted { if ($File::Find::name =~ /\.$ext$/) { $writer-&gt;startTag($file_type); $writer-&gt;startTag('big_url'); $writer-&gt;characters($File::Find::name); $writer-&gt;endTag(); $writer-&gt;endTag(); } } sub GenerateXml { my $filename = shift; my $directory = shift; my $output = new IO::File("&gt;$filename"); $writer = new XML::Writer( OUTPUT =&gt; $output ); $writer-&gt;xmlDecl( 'UTF-8' ); $writer-&gt;startTag( $group_name, 'xmlns' =&gt; 'http://mydomain.com/'.$group_name, 'version' =&gt; '1.0' ); find(\&amp;wanted, $directory); $writer-&gt;endTag(); } package main; FilesToXml::SetRequestedType('docs', 'doc', 'docx'); FilesToXml::GenerateXml("output.xml", "."); </code></pre> <p>You basically need to call <code>SetRequestedType</code> with the type of the files group, the string describing a single file and the file extension. Then you just need to call <code>GenerateXml</code> with the XML output file name and the directory to search under.</p> <p>It works using ActivePerl on Windows. May need some minor adjustments in other environments.</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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