[thelist] replacing unwanted data with PHP in xml file...

Hassan Schroeder hassan at webtuitive.com
Mon Dec 30 17:49:01 CST 2002


Tom Dell'Aringa wrote:

> The text again I have is:
> ------------------------------
> HTTP/1.1 200 OK
> Date: Mon, 30 Dec 2002 21:31:31 GMT
> Server: Apache/1.3.20 Sun Cobalt (Unix) Chili!Soft-ASP/3.6.2
> mod_jk/1.1.0 mod_ssl/2.8.4 OpenSSL/0.9.6g PHP/4.1.2
> mod_auth_pam_external/0.1 FrontPage/4.0.4.3 mod_perl/1.25
> X-StoreSense: 5.1.0.212
> Cache-Control: no-cache
> Connection: close
> Content-Type: text/xml
>
> <?xml version="1.0"?>
> <XTE>...

> I need to strip everything before the xml declaration before I do my
> fputs($handle, $string);

Why not just read in the file a line at a time and discard the lines
until you see the blank line (\n\n) that separates HTTP headers from
the payload? Then you've got your straight XML to have your way with.

Just a thought -- I don't do much with PHP so I won't try to offer a
working sample!  :-)

P.S. This would also allow you to add some potentially useful error
checking by inspecting the headers; did the server return '200 OK'
or something else? Is the content type actually 'text/xml'? etc...

FWIW!
--
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.






More information about the thelist mailing list