I'm trying to strip out the value that is between <CorpActnEvtId>12345678</CorpActnEvtId>.

By which, I think you mean you want to retrieve the value between the CorpActnEvtid opening and closing tags... (Strip out, to me, usually menas you want to delete it, and leave the rest.)

Parsing it with one of the XML modules is the right answer.

A quick answer, if this is a one-off thing or something, is to use something like

$junk =~ /<CorpActnEvtId>(\d+)<\/CorpActnEvtId>/; my $id = $1;

I might do it that way if I had a pile of data I had to munge up just once, and if I didn't need much more from that snippet of XML. But even so, it's making some assumptions (like the ID is always just digits and there is no whitespace within the tag.) This is terribly brittle and, if you have to do it once, you'll probably have to do it again. So I'm not recommending you do it this way, particularly as you weren't able to work it out on your own.

That said, here's some rope; it's up to you not to hang yourself with it.

-sauoq
"My two cents aren't worth a dime.";

In reply to Re: Strip out value between xml tags by sauoq
in thread Strip out value between xml tags by dirtdog

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, 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, 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.