G'day Ben,

Welcome to the monastery.

Short answer: I'm unable to reproduce your problem.

Longer answer:

I set up $qstat as a here-doc. I changed '... ?revision=1.11"' to 'revision="1.11"' and removed the other elision. Check that your original data (prior to replacing parts with '...') was actually valid XML.

Other than that, I used your code as written. The output was a lone "1" character as was expected from "<slots>1</slots>".

You actually don't need all those '->'s. I tried with the following code and got the same result.

for ($xml->{job_info}{queue_info}{'Queue-List'}('@')) { print $_->{job_list}{slots}; }

I'm not a user of XML::Smart. I had to install this module, so I used the latest 1.79 version. Check that you're also using this or upgrade. Also check for any problems with your OS or Perl version (I'm using 5.18.1 on darwin-thread-multi-2level).

Here's the actual code and data I used for my tests (in the spoiler):

-- Ken


In reply to Re: Parsing XML output from `qstat` by kcott
in thread Parsing XML output from `qstat` by Macslayer

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.