Hi All,
 I've been playing with parsing RDF/XML files using PHP (code snippet
below). However I'm having trouble trying to work out how to actually
format the results in an order. My source is in the form

<title>Politicizing Science</title>

Now I could easily cope with it if it was link, title as I would just
print <a href=$link>$title</a>. However I just can't work out a way of
doing this, this way. My attempt so far is below (mostly debugging code)

function startElement($parser, $name, $attrs) {
    global $depth,$type,$title,$url;
    for ($i = 0; $i < $depth[$parser]; $i++) {
        print "  ";
    $type = $name;

function stopElement($parser, $name) {
    global $depth,$type,$title,$url;
    print "depth parse = $depth[$parser] and  $title !! $url <br> ";

function characterData($parser, $data) {
   global $type,$title,$url;
   if ($data)
    switch ($type) {
        case "ITEM":
        case 'LINK':
        case "TITLE":

$fp= fopen($file,"r");


while ($data = fread($fp,4096))
xml_parse($parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",


As you can see I'm trying to use global variables but I'm just really
unhappy with the quality of the code so any help would be appreciated.


Rus foster
http://www.fsck.me.uk - Rant wibble wave
http://shells.fsck.me.uk - Hosting and stuff

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to