Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

cleanup XML output file

by Anonymous Monk
on Jan 03, 2013 at 04:26 UTC ( #1011392=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hiya monks! I need to know whats up with the following code. The output file is slightly messy with this

[$VAR1 = bless( { '_protocol' => 'HTTP/1.1', '_content' => ' ]
header that needs to be manually removed before it is recognized as an XML file. Also need to remove this
[', '_rc' => 200, '_headers' => bless( { 'connection' => 'close', 'client-response-num' => 1, 'set-cookie' => [ 'JSESSIONID= +BE2F6D38D966061A16CF2F63D893143A; Path=/spectrum/; HttpOnly', 'SMSESSION=" +IjLJvilHyYsuRGRh/POaQ68H5im603oJpRtWTfYztzCuZ0AwpK5bUJejgvJtX45N3GA4d +Uq4nFXF9886gH9HbRARbtTCW3PRsdwnwX7Sz9PSsF7Ji3/RSHfwuoPTQMA74GWCXRXAFD +5fj8IQPYFcJYCydsTbf95vMaSVe+BTHz6kXfWSLtPqt6ubYFIPm0vE0kHHv1y4fSzpSre +Pa8y9+spQuVS1jwq7nm5rYrGyEtwXU/9GUPOagieq7pcv6BfZwBG5O2VLfXa6n0JYCD7a +htTYMKwdiOASHZPPQHyadeRD/1VM0ZvBtA4H7QLiaeHLNLeqaL5QkkIeMaruIIWku6cQy +5QsatB3BYJbHD6QUlKSazNyxkHWYNXt+fsGszJJCu29L86Bk1Ks2k+C8PWUjDIXURlp+H +wg7kk+O/CFgBpij8cp4QpHh7QT16WE4MO1zjxYjGJVFHVTwJlcsFFpCr2V0HJFVdDNxXe +hwo/PwN+X5AFhKBExxKylP4/KSn/lY9IXBrZBPKfmC5PtBhJB1k2eqNZtIBdrRyvyEMep +YxqRIofsSnH7UC1pOhw/MDzUch7YYm6aVf8RhVUst0+u+fCxI1cvt2SpBZgBqYk9FJ2xw +GG5DZ6LbL1TEuP0okjK/B7kV7+Ov8z3O0OZ+9D2VYYFb0mQgEMBU/wbJ0N4YxgMqv1GSy +ejoMHKj7FKCPUdedM6a5mSK6sryDHVl1lTAiYpQ+CCJzBoE9oyMgUhnBj8zT95jn13tQP +AllK0NarvlwGjuOYABKwVJhoMKif3uXGTAyVLyJ+BJlinI57OhvgbZ14ZmAOerKFozhr3 +oLNCAHvhf0XXrSuORePcRs2SGnK2JFXk6SKsewoXVSaG+dR5yN//gme99DDWBO5HdD6yx +W3v/KhNU+i42+GQ40tdiBwPDJ4Vq6EPWvVnKuBPeAEZn4RGlmoaar971AdMk/GKfWpAyo +e5SHRbN36dyFQQspRQc0A5ppxtHynDEr7/2jU="; Version=1;; Path=/' ], 'cache-control' => 'private', 'date' => 'Thu, 03 Jan 2013 04 +:13:13 GMT', 'client-peer' => ' +:8080', 'authorization' => 'Basic c3Bl +Y3RydW06c3BlY3RydW0=', '::std_case' => { 'base' => 'B +ase', 'content-bas +e' => 'Content-Base', 'client-resp +onse-num' => 'Client-Response-Num', 'set-cookie' + => 'Set-Cookie', 'client-peer +' => 'Client-Peer', 'client-date +' => 'Client-Date', 'set-cookie2 +' => 'Set-Cookie2', 'client-tran +sfer-encoding' => 'Client-Transfer-Encoding' }, 'client-date' => 'Thu, 03 Jan +2013 04:15:14 GMT', 'content-type' => 'application +/xml', 'client-transfer-encoding' => +[ + 'chunked' +], 'server' => 'Apache-Coyote/1.1 +', 'expires' => 'Thu, 01 Jan 1970 + 07:30:00 MYT' }, 'HTTP::Headers' ), '_msg' => 'OK', '_request' => bless( { '_content' => '', '_uri' => bless( do{\(my $o = +' +0x10009')}, 'URI::http' ), '_headers' => bless( { 'user-a +gent' => 'WWW-Mechanize/1.72', 'accept +-encoding' => 'gzip', 'author +ization' => 'Basic c3BlY3RydW06UEBzc3cwcmQ= ' }, 'HTTP: +:Headers' ), '_method' => 'GET', '_uri_canonical' => $VAR1->{'_ +request'}{'_uri'} }, 'HTTP::Request' ) }, 'HTTP::Response' ); ]

#!Perl #use strict; use HTTP::Request::Common; use XML::Simple; use XML::Dumper; use Data::Dumper; use WWW::Mechanize; use MIME::Base64; my $url = ' +00a&attr=0x10009'; my $Domain = 'spectrum'; my $UserName = 'spectrum'; my $Password = "P\@ssw0rd"; my $outfile = "result.xml"; my $agent = WWW::Mechanize->new(); my @args = ( Authorization => "Basic " . MIME::Base64::encode( $UserName . ':' . $Password ) ); $agent->credentials( '' , $Domain, $UserName, $Password ); my $results = $agent->get( $url, @args ); #print Dumper($results); open(OUTFILE, ">$outfile") || die "could not open output file"; print OUTFILE Dumper($results); close(OUTFILE); print "done\n";

Is there any code to add/remove/modify? Thanks guys n gals!

Replies are listed 'Best First'.
Re: cleanup XML output file
by Anonymous Monk on Jan 03, 2013 at 07:34 UTC
Re: cleanup XML output file
by Anonymous Monk on Jan 03, 2013 at 15:43 UTC
    That's not an XML file to begin with. That's a Data::Dumper output. Who knows how it got there.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1011392]
Approved by Corion
[stevieb]: I have fixed a boatload of issues across several of my distributions, including a couple that have been nagging for a very long time and were exceptionally difficult to solve. Saving $ before we move, so thought I'd have a code session...
[stevieb]: ...session weekend. Went far better than I could have imagined. Even got a bunch of stuff soldered for another one of my electronics projects on the go, and am working on a fix for a MetaCPAN::Client issue I found
[shmem]: the smaller your boat is, the smaller is the load...
shmem is going to look for problems with C++. Urgh.
choroba has worked on the Pull Request Challenge
[stevieb]: shmem I had to do that yesterday and earlier today (C++ issues). It was only fun after I figured it all out.
[stevieb]: it won't be long before I likely won't have much time to do a lot of coding...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2017-06-25 22:29 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (571 votes). Check out past polls.