http://qs321.pair.com?node_id=164528


in reply to (YA) Perl XML-like parser

The title of your post should be YA piece of code that parses a limited and undefined subset of XML.

XML parsers can be validating (against a DTD) or not (they just test well-formedness), see the XML spec. But a non-validating parser still must cover the whole spec. Nothing is optional in the XML spec. To claim to be an XML parser your code must be able to deal with entities, CDATA sections, comments, PI's...

A couple more cases that your code does not handle:

You should really study XML::SAX::PurePerl for a real XML parser in pure Perl (XML::SOAP::Lite does not parse all of XML, just the subset used by SOAP).

Once again: writing something that parses the specific XML data you have to deal with at the moment is usually quite easy, but writing a real XML parser is _HARD_. You can of course use this parser for your data, but try to remember that it does not parse all of XML, and do not complain if one day it breaks on perfectly valid XML.

And please do not post the code and above all do not pretend it is an XML parser. You are doing a disservice both to other monks and to you.

OK, I think I am done. I will now take off my XML ayatollah hat and resume my normal activities ;--)