parse($cont); } function parse($txt) { $errmsg = ''; $p = xml_parser_create(); $x = xml_parse_into_struct($p, $txt, $vals, $index); /* Find name and description */ $ar =& $index['CDNAME']; $this->cdname = trim($vals[$ar[0]]['value']); if (!$this->cdname) { $errmsg = 'Could not find CDName'; return false; } $ar =& $index['DESCRIPTION']; $this->cddescription = trim($vals[$ar[0]]['value']); if (!$this->cddescription) { $errmsg = 'Could not find CDDescription'; return false; } /* Find Definitions */ $ar =& $index['CDDEFINITION']; $this->cddefs = array(); foreach ($ar as $i) { if ($vals[$i]['type'] != 'open') continue; if ($vals[$i+1]['tag'] != 'NAME') { echo 'Parse error in OCD'; return false; } $name = trim($vals[$i+1]['value']); array_push($this->cddefs, $name); } /* Done */ xml_parser_free($p); return true; } } ?>