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.
In reply to Re: creating an xml file from perl
by ikegami
in thread creating an xml file from perl
by decerebrate
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |