ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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{
11
15 protected $table;
19 protected $file = null;
23 protected $xml = null;
27 protected $value = '';
28
29
35 public function __construct($a_xml)
36 {
37 $this->file = $a_xml;
38 $this->xml = simplexml_load_file($this->file);
39 }
40
41
42 public function startParsing()
43 {
44 global $DIC;
45 $ilDB = $DIC->database();
46
47 $table = $this->xml->xpath('/Table');
48 foreach ($table[0]->attributes() as $k => $v) {
49 $this->table = $v;
50 }
51
52 foreach ($this->xml->Row as $row) {
53 $data = array();
54 foreach ($row->children() as $value) {
55 $type = (string) $value['type'];
56 $content = (string) $value;
57 $data[(string) $value['name']] = array(
58 $type,
59 $content,
60 );
61 }
62 $ilDB->insert($this->table, $data);
63 }
64 }
65}
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.
$row
$type
global $DIC
Definition: saml.php:7
global $ilDB
$data
Definition: bench.php:6