Hi,
I'm new to PHP and I would like to get some help on parsing a response sent from a XLink server.
When the following script runs...
<b>$fp = fsockopen($remote_server, 80);
if ($fp)
{
// Send HTTP request
fputs($fp, $header . $request);</b>
a response is sent back and stored in a variable called response. The response looks like this:
<b>HTTP/1.0 200 OK
Content-Type: text/xml
Date: Tue, 27 Jan 2004 21:21:23 GMT
Server: Apache Tomcat/4.0.6 (HTTP/1.1 Connector)
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE response SYSTEM "http://xlink-server.com/dtd/response.dtd" >
<response requestid="">
<header>
<sender>
....etc...</b>
My goal is to parse the XML portion of the response but the "HTTP response" header is causing me problem. What kind of parse or response manipulation functions in PHP could I use to remove the first 4-5 lines of the response? Or how can I remove that header portion and leave out just the xml portion of the response?
I tried the following while-loop script to search for "<?xml" in the response but got an error:
<b>$found = false ;
while (!feof($fp)) {
$data = fgets($fp, 128);
if (!$found) {
$x = $data.substr($data,0,4) ;
echo $data.substr($data,2,4);
if ($x == '<?xml')
$found = true ;
echo $found ;
}</b>
Also, I'm using "xml_paser_free" to parse the xml repsonse. I know that the xml parser works if I don't have the HTTP response header.
Thanks in advance for any tip or help.
V.