Forum Moderators: coopster

Message Too Old, No Replies

DTD, XML and PHP

         

Pico_Train

3:49 pm on Oct 16, 2008 (gmt 0)

10+ Year Member



Hi!

I'm busy trying to get some XML feeds for a client.

The way I am doing it is I have to post an XML string to an external URL or server using the action in a form.

This XML string includes a Doctype and other important stuff the other Server needs including a "returnURL".

Now when I post my form, it send the external server my request, which then proceeds to send the response in DTD and XML format to the returnURL I specified.

So I send from page A that goes to Server A that returns answer to page B.

Now how do I get to page B to get the response, process the XML and manipulate it? Any tools to receive XML in DTD and digest it I could use?

I've tried a redirect onsubmit in js but it's not working.

Thanks in advance!

[edit]sucky grammar[/edit]

[edited by: Pico_Train at 3:50 pm (utc) on Oct. 16, 2008]

Pico_Train

1:01 pm on Oct 17, 2008 (gmt 0)

10+ Year Member



OK...

Basically I am trying to get data from one server to the other and manipulate it.

AJAX doesn;t work because of cross domain scripting issues.

I got lost on http requests and PEAR.

Any help would be appreciated.

Thanks

omoutop

2:00 pm on Oct 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



try using the curl() functions

a small script to help you start is:

<?php
$data_xml = ""; // put there some xml formatted data
$url = 'http://www.somesite.com/path/to/target/page';
$curlPost = 'data='.urlencode($data_xml );

$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_HEADER, 0);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $curlPost);
curl_setopt($curlHandle, CURLOPT_TIMEOUT, 10);
$content = curl_exec($curlHandle);
curl_close($curlHandle);

echo $content;
?>

this will send your xml data to target server/page and retrieve their responce in $content

hope this will help you

Pico_Train

3:46 pm on Oct 17, 2008 (gmt 0)

10+ Year Member



Thanks! I will give it try although I am not sure I have CURL enabled.

I have php 5 and PEAR installed. Might need some help with curl though if I don't have it!

Pico_Train

3:59 pm on Oct 17, 2008 (gmt 0)

10+ Year Member



Ok.

I used your above code and modified the vars as needed for my purposes and I get this message from the server.

Error! Parser : Request XML ( oracle.xml.parser.v2.XMLParseException: Start of root element expected. Error No:4001)

I can't seem to find anything on that when searching for it with g00gle. Any ideas?