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

Tom Dell'Aringa pixelmech at yahoo.com
Mon Dec 30 17:12:01 CST 2002

Okay, found a easier place to deal with this. Once I get my data, I
have it in a variable BEFORE I actually write it to the dump.xml

I have this code:
$filename = "dump.xml";
$handle = fopen($filename,'w+');
$string = $response;

// $response is the XML with the header information in it that I need
to strip

if(preg_match('/<\?xml/', $string))
$string = preg_replace('/^.*<\?xml/', '<?xml', $string);

//I pulled the above from Carls post hoping that would work.
print $string;
fputs($handle, $string);

Problem is this doesn't replace the header text at all. Since I know
absolutely nothing about regexp, I don't know where this is wrong..

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/ mod_perl/1.25
Cache-Control: no-cache
Connection: close
Content-Type: text/xml

<?xml version="1.0"?>
<Response type="Product" txnid="pm01"
<ProductName>Kiddush Cup #1052</ProductName>

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


var me = tom.pixelmech.webDeveloper();

[Making A Commercial Case for Adopting Web Standards]

Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.

More information about the thelist mailing list