[ic] How to include HTTP GET response in an IC page
DB
DB at m-and-d.com
Wed Jul 26 12:55:18 EDT 2006
> On 07/24/2006 04:55 PM, DB wrote:
>> On my IC-5.4 website I need to create a form with a single input field,
>> the contents of which gets added to a HTTP GET request to a remote site.
>> The reply to the request is if the format:
>>
>> HTTP/1.1 200 OK
>> Content-Type: text/xml; charset=utf-8
>> Content-Length: length
>>
>> <?xml version="1.0" encoding="utf-8"?>
>> <ArrayOfString xmlns="http://www.remote-site.com">
>> <string>string</string>
>> <string>string</string>
>> </ArrayOfString>
>>
>>
>> I want to extract the contents of the first instance of
>> <string>string</string>, and display that on the form's results page.
>> Can anyone help by example or point me to the proper docs?
>
> Use the [get-url] tag
> <http://www.interchange.rtfm.info/docs/frames/ictags_144.html> to fetch
> the remote page, then use perl regular expressions to filter out the
> content you want. Something like this should do it:
>
> [calcn]
> my $page = $Tag->get_url('http://www.example.com/mypage.xml');
> $page =~ m!<string>(.+?)</string>!;
> $1;
> [/calcn]
>
> Peter
The tag works if I use it like this:
[get-url "http://example.com/mypage.xml"]
and if I view the source of the resulting page I see:
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.example.com">
<string>the_result</string>
<string xsi:nil="true" />
</ArrayOfString>
as expected. However if I try
[calcn]
my $page = $Tag->get_url('http://www.example.com/mypage.xml');
$page =~ m!<string>(.+?)</string>!;
$1;
[/calcn]
then all I see is 0
I tried escaping the / using
[calcn]
my $page = $Tag->get_url('http://www.example.com/mypage.xml');
$page =~ m!<string>(.+?)<\/string>!;
$1;
[/calcn]
But I still get just 0
Can anyone help me figure out what's wrong ?
DB
More information about the interchange-users
mailing list