예제 #1
0
 /**
  * Parse given root XML
  * 
  * @access public
  * 
  * @param $path      URL to root XML
  * 
  * @throws at.mkweb.upnp.exception.UPnPException     if unable to load root XML
  */
 public function parse($path)
 {
     parent::__construct($path);
     $xml = file_get_contents($path);
     // Debugging
     // header('Content-Type: text/xml');
     // echo $xml; exit;
     if (false == $xml) {
         throw new UPnPException('Unable to load root XML: ' . $path);
     }
     $doc = new DOMDocument();
     $doc->loadXML($xml);
     $root = $doc->childNodes->item(0);
     if ($root->hasChildNodes()) {
         foreach ($root->childNodes as $rootChild) {
             if ($rootChild->tagName == 'specVersion') {
                 $this->parseSpecVersion($doc, $rootChild);
             }
             if ($rootChild->tagName == 'device') {
                 $this->parseDevice($doc, $rootChild);
             }
         }
     }
 }
예제 #2
0
 /**
  * Parse given service XML
  * 
  * @access public
  * 
  * @param $path      URL to service XML
  * 
  * @throws at.mkweb.upnp.exception.UPnPException     if unable to load service XML
  */
 public function parse($path)
 {
     parent::__construct($path);
     $path = trim($path);
     $xml = file_get_contents($path);
     // Debugging:
     // header('Content-Type: text/xml');
     // echo $xml; exit;
     if (false == $xml) {
         throw new UPnPException('Unable to load service XML: ' . $path);
     }
     $doc = new DOMDocument();
     $doc->loadXML($xml);
     $root = $doc->childNodes->item(0);
     if ($root->hasChildNodes()) {
         foreach ($root->childNodes as $childNode) {
             switch ($childNode->tagName) {
                 case 'specVersion':
                     $this->parseSpecVersion($doc, $childNode);
                     break;
                 case 'actionList':
                     $this->parseActionList($doc, $childNode);
                     break;
                 case 'serviceStateTable':
                     $this->parseStateVars($doc, $childNode);
                     break;
             }
         }
     }
 }