Hi,
Hi,
I have some sample code that posts some XML content to an URL using LWP agent
and XML Smart. The response to this comes back as some custom XML. I now need
to try and parse the response and find the REDIRECTURL value and redirect the
client to that destination.
I am having issues parsing the output here is what I have tried.
my $response = $ua->post($webpage, Content_Type => 'text/xml', Content =>
$message);
$response->decoded_content;
if ($response->is_success) {
my $xml = new XML::Smart( "$resonse->content" ,
'XML::Smart::HTMLParser' );
my $xml = new XML::Smart( "$resonse->content" , 'html' );
print "\n\n FOUND:$xml\n"; # comes back with a null value
##########################################################
# another attempt below
###############################
my $response = $ua->post($webpage, Content_Type => 'text/xml', Content =>
$message);
$response->decoded_content;
if ($response->is_success) {
my $html = $response->content;
while ( $html =~/REDIRECT/g ) {
print "I found: $1\n";
} else {
print “nothing found\n”;
};
The find the value REDIRECT as the script prints out “I found: “ and not
“nothing found” but I need the url value….
Here is a sample of what the xml looks like that I am trying to parse.
<PHC_LOGIN>\r
<VERSION>3.0</VERSION>\r
<PARTNERID>111111</PARTNERID>\r
<USERLOGIN>John.doe</USERLOGIN>\r
<ERROR_CODE>0</ERROR_CODE>\r
<ERROR_DESCRIPTION>Login Successful</ERROR_DESCRIPTION>\r
<REDIRECTURL>https://example.com/cust/login.asp</REDIRECTURL>\r
</PHC_LOGIN>
Thanks in advance for any tips you can provide.
-angus