but when i try to generate the xml file i can't please help me
print " FILEXML <Structures>"; #print "<?xml version="1.0" encoding="ISO-8859-1"?>";
Uh oh... for a start, the order of these two items should be reversed. The "<?xml ..?>" tag should be the first thing you output.
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>"; ... }
And here, you appear to be assuming that your data text may never contain any reserved characters, like "<" and "&". These two must be encoded.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.