<head>
<title>Tweakers.NET Headlines</title>
</head>
<body>
<?php

/* Functies aanmaken */
function startElementFOK ($parser,$name,$attrib)
        {
        global $check;
        global $checktitle;
        global $checklink;
        if ($check=='true') {
            if ($name=="TITLE") {
                $checktitle = 'true';
                } else {
                $checktitle = 'false';
                }
            if ($name=="LINK") {
                $checklink = 'true';
                } else {
                $checklink = 'false';
                }
            }
        if ($name=="ITEM") { $check = 'true'; }
        }

function endElementFOK ($parser,$name)
        {
        global $check;
        global $checktitle;
        global $checklink;
        if ($check=='true') {
            if ($name=="TITLE") {
                $checktitle = 'false';
                } else {
                $checktitle = 'false';
                }
            if ($name=="LINK") {
                $checklink = 'false';
                } else {
                $checklink = 'false';
                }
            }
        if ($name=="ITEM") { $check = 'false'; }
        }

function characterDataFOK ($parser, $data)
        {
        global $check;
        global $checktitle;
        global $checklink;
        global $linkdata;
        global $i;

        if ($check=="true") {
             if ($checktitle=='true')
                {
                $linkdata = $data;
                }
             if ($checklink=='true')
                {
                        if ($i<10) {
                                echo "<a href=\"".$data."\" class=\"link\">".$linkdata."</a><br>";
                                $i++;
                                }
                }

             }
        }



// Starten
if (!($fp=@fopen("http://www.tweakers.net/feeds/nieuws.xml", "r")))
        {
        die ("Kan het XML bestand niet openen.");
        }

$i=0;

if (!($xml_parser = xml_parser_create()))
        {
        die("De XML Parser wordt niet ondersteund.");
        }

/* Gegevens verwerken */
xml_set_element_handler($xml_parser,"startElementFOK","endElementFOK");
xml_set_character_data_handler( $xml_parser, "characterDataFOK");

while( $data = fread($fp, 4096))
        {
        if(!xml_parse($xml_parser, $data, feof($fp)))
                {
                break;
                }
        }

/* Parser vrijgeven */
xml_parser_free($xml_parser);
?>
</body>
</html>