|more useful options|
Valid XML and XML::Simpleby mrguy123 (Hermit)
|on Oct 28, 2007 at 09:01 UTC||Need Help??|
mrguy123 has asked for the
wisdom of the Perl Monks concerning the following question:
I have been using the Perl Module XML::Simple quite a lot recently to parse XML and to test if XML is valid and well formed. Everything works great except for one problem.
Sometimes the XML I need to parse has ":" inside the tags, according to certain namespaces. For example
This is not valid XML according to W3C standards. If you save this as an XML file, and try to open it, you get an error. Also, if you go to http://www.w3schools.com/dom/dom_validate.asp and try to validate the XML, you get this error: "reference to undeclared namespace 'person'". My problem is that XML::Simple does not consider this XML invalid. For example, this code does not return an error:
Since I am now working on a project to transform invalid XML to valid XML, and am also using a C XML parser that returns an error for this sort of XML, I have a problem. I know how to make the XML valid, but I also want XML::Simple to fail if the XML is invalid. Does anyone have any ideas what to do?
---A truth that's told with bad intent beats all the lies you can invent
Update: Fixed typo XML::simple -> XML::Simple
Update 2: Added an example from w3schools