On Tue, Dec 22, 2009 at 9:54 AM, Mike Blezien <mick...@frontiernet.net>wrote:
> were using the XML/Simple module to process a XML response using the code > below. But for some reason the module can't read the $xmlresponse data > unless we create a temp file first to store the data then pass that to the > module. Is there a way to do this without having to create a temp file > first. ?? Everything does work, the response is return. We used the > Data/Dumper module to verify the data first. > > ========================================================= > my $ua = new LWP::UserAgent; > $ua->timeout(10); > $ua->agent("HTTP/1.1"); > my $req = new HTTP::Request 'POST' => "$xmlscript"; > $req->content_type("application/x-www-form-urlencoded"); > $req->content($xmlrequest); > my $res = $ua->request($req); > > my $error = $res->is_error(); > my $success = $res->is_success(); > > # Data returned in XML Format > my $xmlresponse = $res->content(); > > my $simple = new XML::Simple(KeyAttr=>[]); > # read XML file > my $xmldata = $simple->XMLin("$xmlresponse"); > # can't read the response in this manner > =================================================== > Try the "parse_string" method instead. The documentation says that XMLin guesses based on the presence of "<" and ">" characters. It appears that XMLin guesses wrong in your case. "parse_string" explicitly expects an XML string. So there's no logic to confuse. -- Robert Wohlfarth