"So what's wrong with that?"
Murphy will rear 'is ugly and head and next thing you know
the XML will need be nested:
...
<name>
<first_name>Foo</first_name>
<last_name>Bar</last_name>
</name>
...
and attributes will be needed:
...
<name part="first">John</name>
<name part="last">Smith</name>
...
.. and more goodies waiting around the corner for anyone
trying to write a parser that has never written any kind
of compiler. I personally do not like to waste valuable time reinventing a wheel that only takes a few moments to install. You download it, you install it, you write stuff that matters and you don't worry about the issues i pointed out.
But .... IF and if that XML will never get more
complicated that originally posted, then your code should
suffice. However, a "real" XML parser does not 10 lines of
code make, just take a look at XML::SAX::PurePerl.
;)
UPDATE:
Now you are just being silly
graff. My whole point was
that one shouldn't have to worry "as the need arises". Not
when all you do is install a CPAN module (i like
BrowserUk's suggestion:
XML::Parser::Lite).
mcogan1966 - you are in for a bumpy ride. Please take
BrowserUk's suggestion. If you really are "Lord and
Master", then use a module for this. But don't take my word for it (besides, what could i possibly know about projects
that never finish because of red tape?) just wait till Murphy gets you. ;)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.