コード例 #1
0
ファイル: ToDOMNodeList.php プロジェクト: mda-php/ddu
 /**
  * Extracts DOMNodeList from any kind of DOM objects
  *
  * @param $DOMObject
  * @param \DOMElement|\DOMNode|\DOMNodeList|\DomDocument $DOMObject
  * @throws \MDA\DDU\Exception
  * @return \DOMNodeList
  */
 public static function extract($DOMObject)
 {
     if ($DOMObject instanceof \DOMNodeList) {
         return $DOMObject;
     } elseif ($DOMObject instanceof \DOMDocument) {
         return $DOMObject->childNodes;
     } elseif ($DOMObject instanceof \DOMNode) {
         return Source\XPath::create(new Source\Pointer\XPath('.'), $DOMObject)->getData();
     }
     throw new Exception(Exception::ERR_UNSUPPORTED_DOM_OBJECT);
 }
コード例 #2
0
ファイル: ToDOMTest.php プロジェクト: mda-php/ddu
 public function testXpathWithNodeNamespace()
 {
     $defaultNamespace = 'http://foo';
     $nestedNamespace = 'http://bar';
     $value = array('table' => array('@attr' => array('xmlns' => $defaultNamespace, 'xmlns:test' => $nestedNamespace), 'test:row' => array()));
     $dom = ToDOM::extract($value);
     $this->assertEquals('row', DOM\Source\XPath::create(new DOM\Source\Pointer\XPath('/xmlns:table/test:row', array('test' => $nestedNamespace)), $dom)->getFirstNode()->localName);
 }