6 private $xmlDataString; // the xml data as string
\r
7 private $captionCollection; // the Caption Collection
\r
10 function __construct($theXmlString)
\r
12 $this->xmlDataString = $theXmlString;
\r
14 // create a caption Collection
\r
15 $myCaptionCollcton = new CaptionCollection();
\r
16 $this->captionCollection = $myCaptionCollcton;
\r
18 // start loopXmlData
\r
19 $this->loopXmlData();
\r
21 } // end constructor
\r
24 * Parses an XML string into an myltidimentional array
\r
26 * @param String $theXmlString The xml file as string
\r
27 * @return Array $xmlInArray
\r
29 public function loopXmlData()
\r
31 // create XML parser
\r
32 $p = xml_parser_create();
\r
34 //xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
\r
36 xml_parse_into_struct($p, $this->xmlDataString, $vals, $index);
\r
39 xml_parser_free($p);
\r
42 // create a Xmlparse Object tracing for <P> tags at level 4 (this the case of DFXP files)
\r
43 $myXmlParse = new XmlParse('P','4');
\r
46 // start looping xml array
\r
47 for ($i = 0; $i < count($vals); $i++)
\r
49 $myXmlParse->setXmlData();
\r
52 // *************************************** GET CAPTION DATA ---- START
\r
54 // if P tag is complete
\r
57 // get caption value
\r
58 $ccText = $vals[$i]['value'];
\r
60 // get attributes array
\r
61 $capAttrib = $vals[$i]['attributes'];
\r
63 // get time in and out of the caption
\r
64 $ccTimeIn = $capAttrib['BEGIN'];
\r
65 $ccTimeOut = $capAttrib['END'];
\r
67 $newCaptionDone = 1;
\r
69 $newCaption = new Caption($ccTimeIn,$ccTimeOut,$ccText,$noStyles);
\r
73 } else if($ccBuild == 1) {
\r
77 // if there are other tags inside P
\r
78 } else if (($ccBuild == 2) && isset($vals[$i]['value'])) {
\r
80 // add other parts of the caption text
\r
81 $ccText .= $vals[$i]['value'];
\r
83 // if is the end of the caption
\r
84 } else if (($ccBuild == 4) && isset($vals[$i]['value'])) {
\r
86 // add other parts of the caption text if is set
\r
87 $ccText .= $vals[$i]['value'];
\r
91 // *************************************** GET CAPTION DATA ---- END
\r
93 // just print each tag info
\r
94 echo '<br/>Tag: '.$vals[$i]['tag'];
\r
95 echo '<br/>Type: '.$vals[$i]['type'];
\r
96 echo '<br/>Level: '.$vals[$i]['level'];
\r
98 if(isset($vals[$i]['attributes']))
\r
100 foreach ($vals[$i]['attributes'] as $theAtt => $theVal)
\r
102 //echo '<br/>Attributes: '.$vals[$i]['attributes'];
\r
103 echo '<br/>------ '.$theAtt.': '.$theVal;
\r
107 if(isset($vals[$i]['value']))
\r
109 echo '<br/>Value: '.$vals[$i]['value'];
\r
132 echo "Index array\n";
\r
133 echo "Total in array Index: ".count($index)."\n";
\r
135 echo "\nVals array\n";
\r
136 echo "Total in array vals: ".count($vals)."\n";
\r
143 foreach($vals as $val)
\r
145 $totInArr = count($val);
\r
146 echo '<br/>tot in Val = '.$totInArr;
\r
147 //echo '<br/>Val = '.$val;
\r
148 foreach ($val as $theVal)
\r
150 echo '<br/>the val = '.$theVal;
\r
160 } // end loopXmlData()
\r
166 public function toString()
\r
168 echo '<br/> xmlDataString: '.$this->xmlDataString;
\r
169 echo '<br/> tagToTrace: '.$this->tagToTrace;
\r
170 echo '<br/> tagToTraceLevel: '.$this->tagToTraceLevel;
\r
173 } // end XmlManager class
\r