msbalaji has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I try to check well-form of the XML file(without entity expanstion, using "NoExpand" option), it is not working what is the problem?
Updated: I need this, if entity is appeared in that XML file, that declaration should be ignored. What is the way to do this?
I try with below code<!ENTITY e SYSTEM “e.xml”> For example, &e; should not be replaced with corresponding entity.
use XML::Parser; my $xmlfile = do {local $/, <DATA>}; my $parser = XML::Parser->new( ErrorContext => 2, NoExpand => 1 ); eval { $parser->parsefile( $xmlfile ); }; if( $@ ) { print STDERR "\nERROR in '$xmlfile':\n$@\n"; } else { print STDERR "'$xmlfile' is well-formed\n"; } __DATA__ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE test [ <!ENTITY e SYSTEM "a.pl"> ]> <test> <customer> <first-name>J&e;oe</first-name> <surname>Wrigley</surname> <address> <street>17 BeÜable Ave.</street> <city>Meatball</city> <state>MI</state> <zip>82649</zip> </address> <email>joewrigley@jmac.org</email> <age>42</age> </customer> <customer> <first-name>Henrietta</first-name> <surname>Pussycat</surname> <address> <street>R.F.D. 2</street> <city>Flangerville</city> <state>NY</state> <zip>83642</zip> </address> <email>meow@263A.org</email> <age>37</age> </customer> </test>
Thanks
Balaji. M
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: NoExpand option in XML::Parser
by moritz (Cardinal) on Jul 09, 2008 at 13:19 UTC |