ILIAS  release_7 Revision v7.30-3-g800a261c036
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 */
3
9{
10
14 protected $table;
18 protected $file = null;
22 protected $xml = null;
26 protected $value = '';
27
28
34 public function __construct($a_xml)
35 {
36 $this->file = $a_xml;
37 $this->xml = simplexml_load_file($this->file);
38 }
39
40
41 public function startParsing()
42 {
43 global $DIC;
44 $ilDB = $DIC->database();
45
46 $table = $this->xml->xpath('/Table');
47 foreach ($table[0]->attributes() as $k => $v) {
48 $this->table = $v;
49 }
50
51 foreach ($this->xml->Row as $row) {
52 $data = array();
53 foreach ($row->children() as $value) {
54 $type = (string) $value['type'];
55 $content = (string) $value;
56 $data[(string) $value['name']] = array(
57 $type,
58 $content,
59 );
60 }
61 $ilDB->insert($this->table, $data);
62 }
63 }
64}
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 $DIC
Definition: goto.php:24
$type
global $ilDB
$data
Definition: storeScorm.php:23