ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilSimpleXMLTableDataParser.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3require_once('./Services/Xml/classes/class.ilSaxParser.php');
4
10
14 protected $file = null;
18 protected $xml = null;
22 protected $value = '';
23
24
30 public function __construct($a_xml) {
31 $this->file = $a_xml;
32 $this->xml = simplexml_load_file($this->file);
33 }
34
35
36 public function startParsing() {
37 global $ilDB;
38
39 $table = $this->xml->xpath('/Table');
40 foreach ($table[0]->attributes() as $k => $v) {
41 $this->table = $v;
42 }
43
44 foreach ($this->xml->Row as $row) {
45 $data = array();
46 foreach ($row->children() as $value) {
47 $type = (string)$value['type'];
48 $content = (string)$value;
49 $data[(string)$value['name']] = array(
50 $type,
51 $content,
52 );
53 }
54 $ilDB->insert($this->table, $data);
55 }
56 }
57}
58
59?>
An exception for terminatinating execution or to throw for unit testing.
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
__construct($a_xml)
ilSimpleXMLTableDataParser constructor.
global $ilDB