Here what I have done is I created a php script that analyzes your downloaded “xml” data and show you the encoded text.
<?php ini_set('error_reporting', E_ALL);ini_set('display_errors', 'On');ini_set('display_startup_errors', 'On'); $file='plotMe.xml'; // xml filename // there is nothing below that you really need to edit $fh=fopen($file,'r') or die("Couldn't open the file");$xml=fread($fh,filesize($file));fclose($fh); $w=750; // image width$h=750; // image height $im=imagecreatetruecolor($w,$h);imageantialias($im,true); $d=new DOMDocument(); if($d->loadXML($xml)){ $lines=arr($d->getElementsByTagName('Line')); $arcs=arr($d->getElementsByTagName('Arc')); foreach($lines as $line){ imageline($im, $line['XStart'], $h-$line['YStart'], $line['XEnd'], $h-$line['YEnd'], color((!isset($line['Color']))?null:$line['Color']) ); } foreach($arcs as $arc){ $len=$arc['Radius']*2; imagearc($im, $arc['XCenter'], $h-$arc['YCenter'], $len, -$len, $arc['ArcStart'], $arc['ArcStart']+$arc['ArcExtend'], color((!isset($arc['Color']))?null:$arc['Color']) ); } } else die("WTF? Couldn't loadXML().."); header('Content-Type: image/png');imagepng($im); function arr($os){ foreach($os as $o){ $tmp=array(); if($o->childNodes->length){ foreach($o->childNodes as $node){ $tmp[$node->nodeName]=$node->nodeValue; } } $ret[]=$tmp; } return $ret; } function color($c){ switch($c){ case 'blue': return 255; case 'green': return 65280; case 'red': return 16711680; case 'yellow': return 16776960; default: return 16777215; } } ?> |
No comments:
Post a Comment