Guest User

Eve CDATA problem

a guest
Jul 29th, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. $xml2 = thunkagexml_load_string( $xmlString, "messageID=" );
  2. // $xml2 = thunkagexml_load_string( $xmlString, "notificationID=" );
  3.  
  4. // if this is in a loop then add onto the arrays with following:                   
  5. if($xml2)
  6.     $MailBodies += $xml2;
  7.  
  8.  
  9. function thunkagexml_load_string( $xmlString, $fieldType )
  10. {
  11.     // simplexml_load_string is unable to handle the CDATA stuff, therefore using my own interpreter - used for mailbodies
  12.     // fieldType for mailbodies = "messageID="
  13.     // fieldType for notificationtexts = "notificationID="
  14.     if(strpos($xmlString,"<row ".$fieldType) !== false)
  15.     {
  16.         while($rowStart = strpos($xmlString,"<row ".$fieldType, $rowEnd))
  17.         {
  18.             $rowEnd = strpos($xmlString, "]]></row>", $rowStart);
  19.             $messageIDStart = $rowStart + 6 + strlen($fieldType);
  20.             $messageIDEnd = strpos($xmlString, '"><![CDATA[', $rowStart);
  21.             $messageBodyStart = $messageIDEnd + 11;
  22.             $messageID = (integer)substr($xmlString,$messageIDStart,($messageIDEnd - $messageIDStart));
  23.             $messageBody = (string)substr($xmlString,$messageBodyStart,($rowEnd - $messageBodyStart));
  24.             $tmp[$fieldType] = $messageID;
  25.             $tmp['messageBody'] = $messageBody;
  26.             //var_dump($tmp);
  27.             $returnArray[$messageID] = $tmp;
  28.             $tmp = NULL;
  29.         }
  30.         return $returnArray;
  31.     } else {
  32.         return NULL;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment