mrguy123 has asked for the wisdom of the Perl Monks concerning the following question:
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:<person> <person:name>Joe</person:name> <person:job>programmer</person:job> </person>
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?#!/exlibris/metalib/m4_b/product/bin/perl use strict; use XML::Simple; my $source_code = "<person> <person:name>Joe</person:name> <person:job>programmer</person:job> </person>"; my $xs = new XML::Simple(); my $hash; ##This should return an error!! eval {$hash = $xs->XMLin($source_code)}; if ($@){ print "$@"; exit(0); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Valid XML and XML::Simple
by GrandFather (Saint) on Oct 28, 2007 at 09:41 UTC | |
by mrguy123 (Hermit) on Oct 28, 2007 at 09:54 UTC | |
by erroneousBollock (Curate) on Oct 28, 2007 at 13:06 UTC | |
by mrguy123 (Hermit) on Oct 28, 2007 at 10:10 UTC | |
|
Re: Valid XML and XML::Simple
by pKai (Priest) on Oct 28, 2007 at 12:24 UTC | |
by mrguy123 (Hermit) on Oct 28, 2007 at 13:57 UTC | |
by Jim (Curate) on Oct 29, 2007 at 00:33 UTC | |
by Anonymous Monk on Oct 28, 2007 at 22:41 UTC | |
|
Re: Valid XML and XML::Simple
by Anonymous Monk on Oct 28, 2007 at 09:32 UTC | |
by mrguy123 (Hermit) on Oct 28, 2007 at 09:51 UTC | |
by Anonymous Monk on Oct 28, 2007 at 12:06 UTC | |
by Anonymous Monk on Oct 28, 2007 at 12:00 UTC |