I'm confused. On more than one aspect of the question.

I'm confused about why you want to avoid XML::Generator's auto-escaping of data. Because when you use an XML parser, the data should be auto-unescaped.

I'm also confused about your data format. Using imageurl# as tagnames seems to be the equivalent of, well, using $var1, $var2, $var3, etc., and variable names and then trying to access them via eval STRING. Instead, I would expect:

<imageinfo> <image number="1"> <url>http://www.company.com/images/photo1.jpg</url> <caption>Caption 1</caption> </image> <image number="2"> <url>http://www.company.com/images/photo2.jpg</url> <caption>Caption 2</caption> </image> <image number="3"> <url>http://www.company.com/images/photo3.jpg</url> <caption>Caption 3</caption> </image> <image number="4"> <url>http://www.company.com/images/photo4.jpg</url> <caption>Caption 4</caption> </image> </imageinfo>
This should make things easier to deal with in many ways. (The number attribute probably shouldn't be there either.)

I'm just not sure why you're doing things this way - both the attempt to bypass escaping, and the data layout.


In reply to Re: nested loops and escaping in XML::Generator by Tanktalus
in thread nested loops and escaping in XML::Generator by geektron

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.