Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
Think about Loose Coupling
 
PerlMonks  

RPC connection to eXist XML O.K how to print results to file

by spencerr1 (Novice)
on May 04, 2013 at 18:04 UTC ( #1032064=perlquestion: print w/ replies, xml ) Need Help??
spencerr1 has asked for the wisdom of the Perl Monks concerning the following question:

I have connected to an eXist XML database and find a xml file and print the contents of the file to the consol is there a way to print the contents to a file instead.

#!/usr/bin/perl use RPC::XML; use RPC::XML::Client; print "Please specify a document path as first argument"; chomp($doc = <STDIN>); if(!$doc) { die "Please specify a document path as first argument!\n"; } $URL = "http://admin:spencerr\@localhost:8080/exist/xmlrpc"; print "connecting to $URL...\n"; $client = new RPC::XML::Client $URL; # Output options $options = RPC::XML::struct->new( 'indent' => 'yes', 'encoding' => 'UTF-8'); $req = RPC::XML::request->new("getDocument", $doc, $options); $resp = $client->send_request($req); if($resp->is_fault) { die "An error occurred: " . $resp->string . "\n"; } print $resp->value . "\n";

Comment on RPC connection to eXist XML O.K how to print results to file
Download Code
Re: RPC connection to eXist XML O.K how to print results to file (print to file)
by Anonymous Monk on May 04, 2013 at 18:25 UTC
Re: RPC connection to eXist XML O.K how to print results to file
by ww (Bishop) on May 04, 2013 at 19:21 UTC
    As you said, after the last time the Monks provided links to the information about how to do this, " Hopefully some day I will be able to contribute. "

    Gotta' agree w/AnonyMonk: you really should read and undertand the replies and information you already have, before posting another question bringing little more than embarrassment disgrace on your head.


    If you didn't program your executable by toggling in binary, it wasn't really programming!

      Sorry about that I do have my challenges with printing to file. Sorry again

      #!/usr/bin/perl use RPC::XML; use RPC::XML::Client; # print "Please specify a document path as first argument"; # chomp($doc = <STDIN>); chomp($doc = "/db/Shakespeare/hamlet.xml"); if(!$doc) { die "Please specify a document path as first argument!\n"; } $URL = "http://admin:spencerr\@localhost:8080/exist/xmlrpc"; print "connecting to $URL...\n"; $client = new RPC::XML::Client $URL; # Output options $options = RPC::XML::struct->new( 'indent' => 'yes', 'encoding' => 'UTF-8'); $req = RPC::XML::request->new("getDocument", $doc, $options); $resp = $client->send_request($req); if($resp->is_fault) { die "An error occurred: " . $resp->string . "\n"; } $file = "C:/Results.xml"; open (XMLFILE, ">$file") || die "Can't open file: $!\n"; print XMLFILE $resp->value ."\n"; #print $resp->value . "\n"; close XMLFILE;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1032064]
Approved by sundialsvc4
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (12)
As of 2014-04-23 20:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (554 votes), past polls