The problem with the OP XML sample is that, even when viewed/saved via the "download" link (to eliminate the PM line-wrapping), there is still other line wrapping that needs to be undone on several long lines near the end of the file.

Once that's fixed, a simple bit of work with XPath expressions will get you what you want. I posted some sample code for this a while back, here: Re: XPath command line utility....

If you want to try the script posted there, save it as "exp" somewhere in one of your PATH directories, make it executable, and run a command line like this:

exp -p '//Attribute[@name="Agreement ID"]/Value/@value | //Attribute[@name="Cycle code"]/Value/@value | //Attribute[@name="Subscriber ID list"]/Value/@value' your_file.xml
(NB: I'm using a bash shell, where it's best to use single-quotes on the outside and double-quotes inside.) When I ran that on the (edited version of) the posted XML data, I got:
15827134 1301 15846291 15613501
The first number is the "Agreement ID", the next is the "Cycle Code", and the rest are the "Subscriber ID list".

(The XPath expressions for this are a bit bulky, but once you grok the syntax, it's a lot easier than writing code.)


In reply to Re: XML Parsing by graff
in thread XML Parsing by munjalm

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.