0
**I have a string**

$string ="   HTTP/1.1 200 OK
    Connection: close
    Date: Tue, 25 Sep 2011 14:09:35 GMT
    Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Server: Apache-Coyote/1.1
    Content-Length: 12881
    Content-Type: text/xml;charset=utf-8
    Client-Date: Tue, 25 Sep 2012 14:09:35 GMT
    Client-Peer: 123.46.53.940:8080
    Client-Response-Num: 1



<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
    <soap-env:Header/>
    <soap-env:Body>
        <PlexViewResponse Command="rtrv-ngfs-subscriber-v2" CongestionIndicator="false" Fsdb="fsdb0" RequestId="" SessionId="Imsptools01:7524768" Status="SUCCESS" SwitchName="ps3il001fsk2">
            <AlternateOtasRealm>stas-stdn.fsimsgroup0-000.ps1tx001fsk2.cvoip.ims.sbc.com</AlternateOtasRealm>
            <SubParty>
                <DisplayName>SDP-Lite</DisplayName>
                <Category>RESIDENTIALSUBSCRIBER_R2</Category>

                ";

`How do I remove this part of the string

HTTP/1.1 200 OK
    Connection: close
    Date: Tue, 25 Sep 2011 14:09:35 GMT
    Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Server: Apache-Coyote/1.1
    Content-Length: 12881
    Content-Type: text/xml;charset=utf-8
    Client-Date: Tue, 25 Sep 2012 14:09:35 GMT
    Client-Peer: 123.46.53.940:8080
    Client-Response-Num: 1



and get the remaining part.

that is string starting from 

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header/>
<soap-env:Body>
    <PlexViewResponse Command="rtrv-ngfs-subscriber-v2" CongestionIndicator="false" Fsdb="fsdb0" RequestId="" SessionId="Imsptools01:7524768" Status="SUCCESS" SwitchName="ps3il001fsk2">
        <AlternateOtasRealm>stas-stdn.fsimsgroup0-000.ps1tx001fsk2.cvoip.ims.sbc.com</AlternateOtasRealm>
        <SubParty>



        Thanks.`
3
Contributors
4
Replies
8
Views
4 Years
Discussion Span
Last Post by cereal
1

For this you could use regex or simpleXML or DOMdocument or another parsing class.

But if you just need to cut off the header:

$string ='HTTP/1.1 200 OK
    Connection: close
    Date: Tue, 25 Sep 2011 14:09:35 GMT
    Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Server: Apache-Coyote/1.1
    Content-Length: 12881
    Content-Type: text/xml;charset=utf-8
    Client-Date: Tue, 25 Sep 2012 14:09:35 GMT
    Client-Peer: 123.46.53.940:8080
    Client-Response-Num: 1
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
    <soap-env:Header></soap>
    <soap-env:Body>
        <PlexViewResponse Command="rtrv-ngfs-subscriber-v2" CongestionIndicator="false" Fsdb="fsdb0" RequestId="" SessionId="Imsptools01:7524768" Status="SUCCESS" SwitchName="ps3il001fsk2">
            <AlternateOtasRealm>stas-stdn.fsimsgroup0-000.ps1tx001fsk2.cvoip.ims.sbc.com</AlternateOtasRealm>
            <SubParty>
                <DisplayName>SDP-Lite</DisplayName>
                <Category>RESIDENTIALSUBSCRIBER_R2</Category>';


preg_match("/(<soap-env:Envelope.*)/s",$string,$matches);
echo '<pre>' . htmlentities($matches[0]) . '</pre>';

The data you need will be in $matches[0] variable.

0

In addition, I asked that question because if you are using curl, just change the settings, like:

curl_setopt($ch, CURLOPT_HEADER, 0);

and you will get just the XML part. Bye!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.