View Single Post
  #1   Spotlight this post!  
Unread 25-03-2003, 23:28
Trashed20's Avatar
Trashed20 Trashed20 is offline
Boom, Shawalala Boom!
#0862 (PCEP Lighting)
 
Join Date: Jan 2002
Location: Canton, MI
Posts: 528
Trashed20 will become famous soon enough
Send a message via AIM to Trashed20
Listen-to xml parsing example thingie

well, i got bored one day and tried some xml parsing based on some examples i found on the web for Listen-to. don't know if anyone is interested. Prolly not very efficient but hey. I basically just made it output an image (which you can already do) but you could do anything you want with the data. comments are good

PHP Code:
<?php
$file
"http://www.listen-to.com/xml.php/trashed20";
$depth = array();
$data1=array();


function 
startElement($parser$name$attrs) {
global 
$name;
    global 
$depth;
    for (
$i 0$i $depth[$parser]; $i++) {}
    
$depth[$parser]++;
}

function 
endElement($parser$name) {
    global 
$depth;
    
$depth[$parser]--;
}

function 
characterData($parser$data) {
global 
$data1;
if (
$data!="    "){$data1[] =$data;}}

$xml_parser xml_parser_create();
xml_set_element_handler($xml_parser"startElement""endElement");
xml_set_character_data_handler($xml_parser"characterData");
if (!(
$fp fopen($file"r"))) {
    die(
"could not open XML input");
}

while (
$data fread($fp4096)) {
    if (!
xml_parse($xml_parser$datafeof($fp))) {
        die(
sprintf("XML error: %s at line %d",
                    
xml_error_string(xml_get_error_code($xml_parser)),
                    
xml_get_current_line_number($xml_parser)));
    }
}
xml_parser_free($xml_parser);

header ("Content-type: image/jpeg");
$im = @imagecreatefromjpeg ("temp2.jpg"); 
$tc  imagecolorallocate ($im255255255);
$time=date("m/d/y g:i a",$data1[11]);
$track=$data1[7];
$group=$data1[3];
imagestring ($im32307$timeblack);
imagestring ($im312631$groupblack);
imagestring ($im313652$trackblack);
imagejpeg ($im,"",85);
?>
__________________
Where has all the fun gone?

Last edited by Trashed20 : 26-03-2003 at 06:58.