I had no problem getting your code to output the new XML, using valdez's advice. The reason i am posting is because your question states that you want to create a new XML file, yet you are also outputing HTML ... if all you need to do is print out the item codes, you can use XML::XPath, which i find is a better tool for this kind of problem:
use strict; use warnings; use XML::XPath; use CGI::Pretty qw(:standard); my $xpath = XML::XPath->new(ioref => *DATA); my $nodeset = $xpath->find('/profile/bids/itemcode'); my @b_item = map $_->string_value, $nodeset->get_nodelist; print header, start_html('itemcodes'), h1('Then'), (map { $_,br } @b_item), end_html, ; __DATA__ <profile username="Tom" language="eng" lastlogin=""> <bids> <itemcode>4985874875</itemcode> <itemcode>7685976785</itemcode> <itemcode>6758679837</itemcode> <itemcode>7849609576</itemcode> <itemcode>2857689576</itemcode> </bids> <itemwatch> <itemcode>6758767856</itemcode> <itemcode>3758678576</itemcode> </itemwatch> </profile>
One last note, i rarely have to add anything to the XML files that i use. Instead, data is typically stored somewhere else (a database usually) and i use XML as an intermediary transformation. This way, the need to edit an XML file is aleviated, instead, i change the data in the database and create a new XML file. This doesn't always work, but it seems like a much better way to go in the long run ... YMMV, of course. ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to (jeffa) Re: Writing Out XML using XML::Simple by jeffa
in thread Writing Out XML using XML::Simple 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.