but when i try to generate the xml file i can't please help meUh oh... for a start, the order of these two items should be reversed. The "<?xml ..?>" tag should be the first thing you output.print " FILEXML <Structures>"; #print "<?xml version="1.0" encoding="ISO-8859-1"?>";
And here, you appear to be assuming that your data text may never contain any reserved characters, like "<" and "&". These two must be encoded.while( @data = $sth->fetchrow_array() ) { # I GENERATE THE STRUCTURE OF THE XML FILE print FILEXML "<Book>"; print FILEXML "<Author>$data[0]</Author>"; print FILEXML "<Title>$data[1]</Title>"; ... }
If you want a simple module that will take care of that, use XML::Writer. It'll do the special character encoding for you, it'll even check that your tags are properly nested. What it doesn't do is check if your data is in the proper character set, let alone convert it for your. That is your responsibility, although you can tell it to generate the proper "<?xml ... ?>" header at the start.
n.b. Without that header, the data encoding should be in UTF-8, which isn't really the case, it it?
In reply to Re: perl script and xml
by bart
in thread perl script and xml
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |