+++ /dev/null
-<?php\r
-\r
-\r
-class XmlManager\r
-{\r
- private $xmlDataString; // the xml data as string\r
- private $captionCollection; // the Caption Collection\r
- //\r
-\r
- function __construct($theXmlString)\r
- {\r
- $this->xmlDataString = $theXmlString;\r
- \r
- // create a caption Collection \r
- $myCaptionCollcton = new CaptionCollection();\r
- $this->captionCollection = $myCaptionCollcton;\r
- \r
- // start loopXmlData\r
- $this->loopXmlData();\r
- \r
- } // end constructor \r
-\r
- /**\r
- * Parses an XML string into an myltidimentional array\r
- *\r
- * @param String $theXmlString The xml file as string\r
- * @return Array $xmlInArray \r
- */\r
- public function loopXmlData()\r
- {\r
- // create XML parser\r
- $p = xml_parser_create();\r
- \r
- //xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);\r
-\r
- xml_parse_into_struct($p, $this->xmlDataString, $vals, $index);\r
- \r
- // free parser \r
- xml_parser_free($p);\r
- \r
- \r
- // create a Xmlparse Object tracing for <P> tags at level 4 (this the case of DFXP files) \r
- $myXmlParse = new XmlParse('P','4');\r
- \r
- \r
- // start looping xml array\r
- for ($i = 0; $i < count($vals); $i++) \r
- {\r
- $myXmlParse->setXmlData();\r
- \r
- \r
- // *************************************** GET CAPTION DATA ---- START\r
- \r
- // if P tag is complete \r
- if($ccBuild == 3) \r
- {\r
- // get caption value\r
- $ccText = $vals[$i]['value'];\r
- \r
- // get attributes array \r
- $capAttrib = $vals[$i]['attributes'];\r
- \r
- // get time in and out of the caption\r
- $ccTimeIn = $capAttrib['BEGIN'];\r
- $ccTimeOut = $capAttrib['END'];\r
- \r
- $newCaptionDone = 1;\r
-\r
- $newCaption = new Caption($ccTimeIn,$ccTimeOut,$ccText,$noStyles);\r
- //$new\r
- //$countCC++;\r
- \r
- } else if($ccBuild == 1) {\r
- \r
- \r
- \r
- // if there are other tags inside P\r
- } else if (($ccBuild == 2) && isset($vals[$i]['value'])) {\r
- \r
- // add other parts of the caption text\r
- $ccText .= $vals[$i]['value'];\r
- \r
- // if is the end of the caption\r
- } else if (($ccBuild == 4) && isset($vals[$i]['value'])) {\r
- \r
- // add other parts of the caption text if is set\r
- $ccText .= $vals[$i]['value'];\r
- }\r
- \r
- \r
- // *************************************** GET CAPTION DATA ---- END\r
- \r
- // just print each tag info\r
- echo '<br/>Tag: '.$vals[$i]['tag'];\r
- echo '<br/>Type: '.$vals[$i]['type'];\r
- echo '<br/>Level: '.$vals[$i]['level'];\r
-\r
- if(isset($vals[$i]['attributes']))\r
- {\r
- foreach ($vals[$i]['attributes'] as $theAtt => $theVal)\r
- {\r
- //echo '<br/>Attributes: '.$vals[$i]['attributes'];\r
- echo '<br/>------ '.$theAtt.': '.$theVal;\r
- }\r
- }\r
- \r
- if(isset($vals[$i]['value']))\r
- {\r
- echo '<br/>Value: '.$vals[$i]['value'];\r
- }\r
- \r
- echo '<hr>';\r
- } // end for \r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- /*\r
- echo "Index array\n";\r
- echo "Total in array Index: ".count($index)."\n";\r
- print_r($index);\r
- echo "\nVals array\n";\r
- echo "Total in array vals: ".count($vals)."\n";\r
- print_r($vals);\r
- */\r
- \r
- \r
- \r
- /*\r
- foreach($vals as $val)\r
- {\r
- $totInArr = count($val);\r
- echo '<br/>tot in Val = '.$totInArr;\r
- //echo '<br/>Val = '.$val;\r
- foreach ($val as $theVal)\r
- {\r
- echo '<br/>the val = '.$theVal;\r
- \r
- } // end for 2\r
- \r
- } // end for 1\r
- */\r
- \r
- \r
- //return $vals;\r
- \r
- } // end loopXmlData()\r
- \r
- /**\r
- * Print class Data\r
- *\r
- */\r
- public function toString()\r
- {\r
- echo '<br/> xmlDataString: '.$this->xmlDataString;\r
- echo '<br/> tagToTrace: '.$this->tagToTrace;\r
- echo '<br/> tagToTraceLevel: '.$this->tagToTraceLevel;\r
- \r
- }\r
-} // end XmlManager class \r
-?>
\ No newline at end of file