Eigentlich war das nur mal so ein Versuch - auslesen der Trillian History mittels SimpleXML. Im folgenen Beispiel möchte ich nur eine Methode zeigen, wie man es machen könnte.
Der Aufbau der Trillian History sieht etwa so aus:
<session type="start" time="1192308577" medium="AIM" to="UserXYZ" from="Silesia124"/>
<message type="incoming_privateMessage" time="1192308578" medium="AIM" to="Silesia124"
from="UserXYZ" from_display="UserXYZ" text="nabend%2E%2E"/>
<status type="online" time="1192553848" medium="AIM" from="UserXYZ"/> <?php
$content = '<item>';
$content .= file_get_contents('test.xml');
$content .= '</item>';
$xml = new SimpleXMLElement($content);
// zum Testen der Ausgabe
print_r($xml);
?> $content = '<item>'; <?php
function getAttribute($att, $name){
foreach($att as $key=>$val){
if ($key == $name) return (string)$val;
}
}
$log_array = Array();
?> <?php
for ($i = 0; $i < count($xml); $i++ ) {
if ( $xml->session[$i] ) {
$att = $xml->session[$i]->attributes();
$time = getAttribute($att,'time');
$log_array[$time] = Array(
'date' => date('d.m.y H:i', $time),
'type' => getAttribute($att,'type'),
'from' => getAttribute($att,'from'),
'to' => getAttribute($att,'to'),
);
}
if ( $xml->message[$i] ) {
$att = $xml->message[$i]->attributes();
$time = getAttribute($att,'time');
$log_array[$time] = Array(
'date' => date('d.m.y H:i', $time),
'type' => getAttribute($att,'type'),
'from' => getAttribute($att,'from'),
'to' => getAttribute($att,'to'),
'text' => utf8_decode( urldecode( getAttribute($att,'text') ) ),
);
}
if ( $xml->status[$i] ) {
$att = $xml->status[$i]->attributes();
$time = getAttribute($att,'time');
$log_array[$time] = Array(
'date' => date('d.m.y H:i', $time),
'type' => getAttribute($att,'type'),
'from' => getAttribute($att,'from'),
'to' => getAttribute($att,'to'),
);
}
}
print_r( $log_array );
?> Array
(
[1192308577] => Array
(
[date] => 13.10.07 22:49
[type] => start
[from] => Silesia124
[to] => UserXYZ
)
[1192308578] => Array
(
[date] => 13.10.07 22:49
[type] => incoming_privateMessage
[from] => UserXYZ
[to] => Silesia124
[text] => nabend..
)
[1192553848] => Array
(
[date] => 16.10.07 18:57
[type] => online
[from] => UserXYZ
[to] =>
)
)