These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

API Mail Bodies parser CDATA how to

Author
Gallente Drone
Doomheim
#1 - 2012-07-29 21:30:26 UTC  |  Edited by: Gallente Drone
Some php code... http://pastebin.com/K0sN35RW

I use such way (delete "[CDATA]" as string replace and them convert it to object) but we'll got missing messageID, if we delete string with "preg_replace_callback" then we got only messageID without row content... So question is....

How to get both? The messageID and its cocntent (mail body). simplexml_load_string got troubles with CDATA values, there a lots of exmaples but no one works fine with xml MailBodies.xml :(
Captain Thunk
Explode. Now. Please.
Alliance. Now. Please.
#2 - 2012-07-29 23:22:55 UTC
I hit this problem some time ago, I did a dirty quick fix that I never needed to revisit.

To the best of my knowledge it only occurs with mails and notifications.

http://pastebin.com/0h4cuMzJ

it retruns an array with key as the id and the value being the data in question.

Hope this helps. (There maybe a way to do it properly with simplexml, I just wasn't interested in researching it at the time)
Ydnari
Estrale Frontiers
#3 - 2012-07-30 22:58:47 UTC
What problem does simplexml_load_string have with CDATA blocks?

Works fine for me:

$xml = simplexml_load_string(file_get_contents("/home/andyh/projects/eve-data/MailBodies.xml"));
print $xml->result[0]->rowset[0]->row[0];


outputs the body of the first mail. PHP 5.3.10.

--

Gallente Drone
Doomheim
#4 - 2012-07-31 14:51:05 UTC
Ydnari wrote:
What problem does simplexml_load_string have with CDATA blocks?

Works fine for me:

$xml = simplexml_load_string(file_get_contents("/home/andyh/projects/eve-data/MailBodies.xml"));
print $xml->result[0]->rowset[0]->row[0];


outputs the body of the first mail. PHP 5.3.10.

With array is more confortable to work. No need to create check more then once, enough would be if (isset ($array["characterID"])) and to get values the same.
Ydnari
Estrale Frontiers
#5 - 2012-07-31 16:24:33 UTC
Gallente Drone wrote:
Ydnari wrote:
What problem does simplexml_load_string have with CDATA blocks?

Works fine for me:

$xml = simplexml_load_string(file_get_contents("/home/andyh/projects/eve-data/MailBodies.xml"));
print $xml->result[0]->rowset[0]->row[0];


outputs the body of the first mail. PHP 5.3.10.

With array is more confortable to work. No need to create check more then once, enough would be if (isset ($array["characterID"])) and to get values the same.


Sorry, I don't understand what you're saying.

I ought to answer your original question more fully though, you can get both with:

$row = $xml->result[0]->rowset[0]->row[0]; // or from a loop across the rowset for each row
$messageID = (int)$row['messageID'];
$body = (string)$row;

--