Perl XML::LibXML Parser Error
If I am using the XML::LibXML parser to repeatedly call a 开发者_如何转开发line like the following...
$tree = $parser->parse_file($WBCall);
...where $WBCall represents a HTTP string to a service that returns data in XML format, then occasionally I receive an error like the following: ":1: parser error : Start tag expected, '<' not found"
This occurs rarely when the code is pulling in hundreds of XML data files. Does this mean that I need to add in some XML validation? If so, what's the best Perl module for that?
It sounds like you're occasionally getting a response with an empty body, or possibly some sort of "server busy" response.
When you say "$WBCall represents a HTTP string to a service that returns data in XML format" do you mean that it contains a URI? If so, perhaps you could make the HTTP request yourself using LWP and then call $parser->parse_string($response->content)
. In the event of an error (catch it with eval) you could log $response->as_string
.
精彩评论