satyabrata_karan has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monk, LWP::UserAgent get method returns partial XML. Please any idea how to find why the junk XML came and is their any other better substitute for LWP::UserAgent.

my $ua = LWP::UserAgent->new; $ua->timeout(5); my $response = $ua->get($url); unless ($response->is_success) { $self->error( $response->status_line ) ; return undef; } return $response->content; }

Replies are listed 'Best First'.
Re: LWP::UserAgent return partial XML
by Jenda (Abbot) on May 24, 2012 at 08:27 UTC

    LWP::UserAgent doesn't give a damn about that data or what kind of data the server sends. You get what the server sent so either you sent an invalid request and the script on the server produced an invalid response or there's an error on the server or you failed to read the docs and the response is just all right. In the last case if you need to parse the partial XML (missing the root tag), you can store it in a file and parse

    <!DOCTYPE doc [<!ENTITY real_doc SYSTEM "$the_file_name">]><doc>&rea +l_doc;</doc>
    instead.

    (I see a "how do I save XML in a file" question coming ...)

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

Re: partial XML came from server
by Anonymous Monk on May 22, 2012 at 03:16 UTC

    So what I do code change here if I got such type of half XML file from server

    Well, first I would start by reading some documentation that explains the website you're trying to communicate with