No, no and no, for all 3 "parse with index and substr" snippets. How hard is it to use XML::Simple, especially as I believe it can now accept SAX input, and thus does not depend on XML::Parser anymore, so you can use XML::SAX::PurePerl, Matts pure Perl XML parser.

You are not parsing XML here, you are parsing the exact format of the message _today_. Any extra piece of information added, any comment would break this parser, while proper XML code (ie based on a real XML parser) would do just fine. There are plenty of ways the format of the ticker could be changed while the XML view would remain the same: added entities, comments, namespace declarations, you name it... Only a proper XML parser will allow you to extract the information regardless of the exact way the XML is "physically encoded".

You can have fun with this code, but I don't think it is a good thing to show it here.

I suggest you write a second version of those tools using XML::Simple and XML::SAX::PureSax, this way you will learn something, help others by showing them the proper way to process XML, and even garner some ++ in the process.


In reply to Re: parse the "Other Users XML Ticker" with index and substr by mirod
in thread parse the "Other Users XML Ticker" with index and substr by PodMaster

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.