Jump to content

strpos and XML


sKunKbad

Recommended Posts

I'm trying to check for an error message within some XML that is returned from cURL, but strstr and strpos aren't working for me:

 

<?php
$response ="<?xml version='1.0' encoding='UTF8'?><error xmlns='http://incubator.apache.org/abdera'><code>409</code><message>Email address (someemailaddress.com) is already a contact</message></error>1";
// Check for error
  if (strpos($response, "<?xml version='1.0' encoding='UTF8'?><error")) {
      echo "The subscription process failed - try again.<br />";
  }
  echo $response; // echo response, it may contain an error message
?>

 

What's wrong here? Instead of strstr or strpos seeing my needle in the haystack, I just see the haystack output.

Link to comment
https://forums.phpfreaks.com/topic/165546-strpos-and-xml/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.