You've misunderstood the idea behind stream mode I believe. Pure stream mode parsers read the XML bit by bit and when they've recognized a significant chunk (for lack of a better term; e.g. a start tag, an end tag, a stretch of character data) they stop and pass that information back to whatever corresponding callback you've configured. In your example's second <entry> element there looks to be 6 significant chunks:

For what you're sounding like you want (all of the text of an entry regardless of nesting to be one "chunk"), the parser would have to have some way of knowing what start/end tags are significant or ignorable. I believe you might be able to use XML::Twig's stream/tree hybrid mode to get this kind of behavior by setting up a twig_handler for <entry> elements and then calling the text method on the element when that's recognized.

Update: On second read I think you've understood where the problem is you've just gotten stuck trying to figure out how to get around it (and you're on the right track with the stack idea; it's more you'd want an accumulator to which you keep appending your text chunks until you see the outer most end tag)

The cake is a lie.
The cake is a lie.
The cake is a lie.


In reply to Re: confused with Stream style in XML::Parser by Fletch
in thread confused with Stream style in XML::Parser by diamantis

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.