in reply to creating an xml file from perl
Instead of
print FIL "<categoryName>\n";
you'd use
print FIL "<site>\n";
Instead of
print FIL "</pics>\n";
you'd use
print FIL "</site>\n";
Instead of
print FIL "<pic$t name=\"$nfile\"></pic$t>\n";
you'd use
use URI::Escape qw( uri_escape ); my $escaped_file = $nfile; # Convert the file name to a URL. $escaped_file = uri_escape($nfile); # Escape the URL for use in an HTML attribute. #uri_escape already removes & and ". #$escaped_file =~ s/&/&/g; #$escaped_file =~ s/"/"/g; print FIL "<item id=\"$t\" name=\"$escaped_file\" />\n";
btw, it checks for .jpg in lowercase. You may want to replace
substr($filename, length($filename)-4, 4) eq ".jpg"
with
lc(substr($filename, length($filename)-4, 4)) eq ".jpg"
or the simpler
lc(substr($filename, -4)) eq ".jpg"
in case file is named SOMETHING.JPG.
Update: Added uri escaping.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: creating an xml file from perl
by decerebrate (Initiate) on Apr 13, 2005 at 23:55 UTC | |
by ikegami (Patriarch) on Apr 14, 2005 at 02:06 UTC | |
by tlm (Prior) on Apr 14, 2005 at 01:08 UTC | |
|
Re^2: creating an xml file from perl
by polettix (Vicar) on Apr 14, 2005 at 14:01 UTC | |
by ikegami (Patriarch) on Apr 14, 2005 at 14:11 UTC |