Example #1
0
 /** @test */
 public function xpathShouldThrowExceptionWithoutOwnerDocument()
 {
     $element = new DOMElement('foo');
     try {
         $element->xpath('//foo');
     } catch (\BadMethodCallException $e) {
         $this->assertSame('cannot xpath on element without an owner document', $e->getMessage());
     } catch (\Exception $e) {
         $this->fail($e->getMessage());
     }
 }
Example #2
0
 /**
  * A lookahead to find sibling elements with similar names.
  *
  * @param DOMElement $node the node in charge.
  * @param string     $prefix the element prefix
  *
  * @return \DOMNodeList
  */
 private function getEqualNodes(DOMElement $node, $prefix = null)
 {
     $name = $this->prefixKey($node->nodeName, $prefix);
     return $node->xpath(sprintf(".|following-sibling::*[name() = '%s']|preceding-sibling::*[name() = '%s']", $name, $name));
 }