in reply to Re: Perl with XML
in thread Perl with XML

No! Your code does NOT parse XML. It parses a limited subset of XML. It might be OK for the data you handle right now but it means that you cannot change this data. Are the restrictions you put on the XML clearly documented somewhere? Because if you have to receive data from a source that you don't control and if you just tell them "it's XML, here is the DTD/schema" I can tell you that you open the door to tons of problems. People do use entities, comments, processing instructions, namespaces and the likes! And as this regexp based parsing does no validation whatsoever of the incoming XML, how do you know you can trust it?

In short you are using an internal format, that looks a little bit like XML but that is not XML. This is fine except when you call it XML. I understand that the quizz is for applicants to your company only, so it's not like you were advocating your method in a public forum, but I still want to warn people (and you!) against thinking that XML is simple to process using regexps.

BTW if you don't want to use XML::Parser you can also use XML::Parser::Lite, which is regexp based, or libXML, or soon the new XML::SAX::PurePerl or you could use a real (and fast) XML processor to generate a version of the data that you know you can handle (expanding entities, discarding comments...)