Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hello again everyone,

Been a long time since my last post, but I am really stuck this time, and can't figure why.

I am using XML::Parser to parse .RSS documents from and for a "live news feed" if you will. First, below is a snippet from's RSS doc:

<item> <title>Big software companies lose their minds!</title> <link>;aid=12492</link> <description> corresponent Mark Miller has some views on big software companies.</description> </item>

Now, if you look at the <link> tag, you see that there is a proper sequence, &amp; to represent an ampersand. However, here is the problem. When XML::Parser encounters this chunk of data, it calls the Char handler, whatever you define it to be. Mine happens to be very simple, atleast right now (BTW, I am using the Subs style for the parser, but tha shouldn't matter):

sub found_char { my ($ex, $str) = @_; if ($ex->in_element('link') && $ex->within_element('item')) { print "\t\tLink: $str\n"; } }

So I should expect a simple string that has Link: and then the link, whatever that may be. However, it seems that XML::Parser instead, for some reason, splits on that escape sequence, so I get this output:

Link: Link: & Link: aid=12492

What I CANNOT figure out is why it seems to consider that string within the <link> element three strings!

Does anyone know how this can be fixed - I have seen this problem happen with other "non-element" data, and I just want it to grab all of the pertient data at one time.

Thanks a ton!

r. j o s e p h
"Violence is a last resort of the incompetent" - Salvor Hardin, Foundation by Issac Asimov

In reply to XML::Parser breaks on by r.joseph

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2021-10-15 23:06 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (69 votes). Check out past polls.