开发者

Perl XML::LibXML Parser Error

开发者 https://www.devze.com 2023-01-03 11:34 出处:网络
If I am using the XML::LibXML parser to repeatedly call a 开发者_如何转开发line like the following...

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消