Hi, I have piece of code that seems to work fine but changes some characters to entities: Example:
$labl = XML::XPath::Node::Element->new("images"); $nLabelTxt = XML::XPath::Node::Text->new($item_img); $plabel->appendChild( $nLabelTxt); $rootElm->appendChild( $labl );
generates the node as: >>>>>>>>>>>>>>>
<images> &lt;color> &lt;description>color1&lt;/description> &lt;package1>imagePath/file/filename.jpg&lt;/package1> &lt;package2>imagePath/file/filename2.jpg&lt;package2> &lt;/color> &lt;color> &lt;description>color2 &lt;/description> &lt;package1>imagePath/file/filename3.jpg&lt;/package1> &lt;package2>imagePath/file/filename52.jpg&lt;package2> &lt;/color> </images>
<<<<<<<<<<<<<<<

Which is awesome, except for the &lt; instead of < . However note that the images node is fine though!

Now, if I change to code to add another element instead of the Text->new, then I have a differen problem.

$nLabelTxt = XML::XPath::Node::Element->new($item_img);
then the output will be property with < instead of &lt;, but the elements will be like an attribute, as in:
<images> < <color> <description>color1</description> <package1>imagePath/file/filename.jpg</package1> <package2>imagePath/file/filename2.jpg</package2> </color> <color> <description>color2 </description> <package1>imagePath/file/filename3.jpg</package1> <package2>imagePath/file/filename52.jpg</package2> </color> /> </images>
Any clue & help on why this is happening? I can understand why the element being created as attribute but the first piece of code and xml it generates puzzles (pi*****) me . Thanks folks.

In reply to Perl entities, UTF8 with xml XPATH by Narend

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.