Mercurial > hg > extraction-interface
comparison _xampp/contrib/sax.php @ 0:b12c99b7c3f0
commit for previous development
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 19 Jan 2015 17:13:49 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:b12c99b7c3f0 |
---|---|
1 <html> | |
2 <head> | |
3 <title>PHP und SAX</title> | |
4 </head> | |
5 <body> | |
6 <h1>PHP und SAX</h1> | |
7 <table border="1"> | |
8 <tr> | |
9 <th>Titel</th> | |
10 <th>Interpret</th> | |
11 <th>Jahr</th> | |
12 <th>ID</th> | |
13 </tr> | |
14 <?php | |
15 $parser = xml_parser_create(); | |
16 xml_set_element_handler($parser, 'startE','endE'); | |
17 xml_set_character_data_handler($parser, 'characterD'); | |
18 $fp = fopen('cds.xml', 'r'); | |
19 while ($data = fread($fp, 1024)) | |
20 { | |
21 $result = xml_parse($parser, $data); | |
22 } | |
23 fclose($fp); | |
24 | |
25 function startE($parser, $name, $attribs) | |
26 { | |
27 if($name=="ROW") | |
28 { | |
29 echo "<tr>"; | |
30 } | |
31 else if($name=="TITEL" || $name=="INTERPRET" || $name=="JAHR" || $name=="ID") | |
32 { | |
33 echo "<td>"; | |
34 } | |
35 } | |
36 | |
37 function endE($parser, $name) | |
38 { | |
39 if($name=="ROW") | |
40 { | |
41 echo "</tr>"; | |
42 } | |
43 else if($name=="TITEL" || $name=="INTERPRET" || $name=="JAHR" || $name=="ID") | |
44 { | |
45 echo "</td>"; | |
46 } | |
47 } | |
48 | |
49 function characterD($parser, $data) | |
50 { | |
51 print $data; | |
52 } | |
53 ?> | |
54 </table> | |
55 </body> | |
56 </html> |