<?

include("captionConvertClass.php");


$xmlFile = file_get_contents("XMLFILE");

$xmlArray = split("\n", $xmlFile);



//$startTC = "01:00:00;00";
$startTC = "00:00:00:00";

$sccCaptions = new captionConvert($startTC);




foreach($xmlArray as $xmlLine) {

    if(strpos($xmlLine, "p begin")) {

        // Parse the DFXP into two strings, beginTime and captionContents

        preg_match_all('/([a-z]+)="([^"]*)"/', $xmlLine, $beginTime, PREG_PATTERN_ORDER);
        preg_match_all("|<[^>]+>(.*)</[^>]+>|U", $xmlLine, $captionContents, PREG_PATTERN_ORDER);

        
        $beginTime = $beginTime[2][0];
        $captionContents = $captionContents[1][0];

        $sccCaptions->addCaption($beginTime, $captionContents);
        
        
    }
    
}

echo $sccCaptions->outputCaptions();