SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Soap Response - how to grab contents of one part

    I have a soap response i wish to just extract what is in between the following brackets
    PHP Code:
    <ns1:InsuranceGroup>1</ns1:InsuranceGroup

    what would the best way be.

    the whole response comes back from a curl and is called $response as it's variable.

  2. #2
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,397
    Mentioned
    63 Post(s)
    Tagged
    0 Thread(s)
    Is there any reason why you're using cURL, rather than something like PHP's SoapClient?
    Salathe
    Software Developer and PHP Manual Author.

  3. #3
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just using it as a test at the moment.

  4. #4
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can any one help do a pregmatch for it instead?

  5. #5
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,397
    Mentioned
    63 Post(s)
    Tagged
    0 Thread(s)
    Why not show us what you have so far, and folks can help you to make it work the way you want?
    Salathe
    Software Developer and PHP Manual Author.

  6. #6
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,307
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by txt3rob View Post
    can any one help do a pregmatch for it instead?
    Code:
    $string = '<ns1:InsuranceGroup>1</ns1:InsuranceGroup>';
    preg_match('#<ns1:InsuranceGroup>(.+?)</ns1:InsuranceGroup>#',$string,$match);
    $data = $match[1];
    echo '<p>', $data, '</p>';

  7. #7
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you that has worked

    i need to try do a multiple match now to echo out some results

    i have the following
    HTML Code:
                                                        <ns1:Make>
    								
    								<ns1:Description>BMW</ns1:Description>
    							</ns1:Make>
    							<ns1:Model>
    								
    								<ns1:Description>6 SERIES</ns1:Description>
    							</ns1:Model>
    							<ns1:Body>
    								<ns1:Description>5 Door Hatchback</ns1:Description>
    							</ns1:Body>
    							<ns1:Transmission>
                                                             <ns1:Description>5 Speed Manual Petrol</ns1:Description>
    							</ns1:Transmission>
    is there any easy way to extract the make and model and transmission from the returned values there?

    i altered the code above to look for description but now i am stuck as it's hitting about 6 options of description now

  8. #8
    SitePoint Zealot txt3rob's Avatar
    Join Date
    Jul 2013
    Location
    Liverpool UK
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    think i have sorted it now


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •