I would interpret &%2339; as a failed attempt to encode the apostrophe character, as follows:
  1. apostrophe ('  = 0x27) is 39 decimal, so ' is the (decimal) numeric character entity for that
  2. pound (#  = 0x23) gets converted to %23, yielding &%2339;

Since the result of step 2 is an invalid entity reference, either step 2 should not have been done (leaving ' as-is), or the remaining ampersand should have been converted as well, to yield %26%2339; (update: or perhaps it should have been rendered as  &%2339;)

The whole mess could have been avoided if the original apostrophe had been converted to %27, though I'm not sure from your description whether this would actually work either...

Another update: As for actually dealing with that, maybe you want to "pre-condition" the text before passing it to XML::TreeBuilder -- e.g. if you have the whole xml string in a scalar called "$text", you could do this:

$text =~ s/\%([0-9A-F]{2})/chr(hex($1))/eg;
(or be more particular/ad-hoc, and just do  s/\%23/\#/g;) Then pass $text to Treebuilder. That might put things right.

In reply to Re: XML::TreeBuilder invalid token problem by graff
in thread XML::TreeBuilder invalid token problem by cormanaz

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.