Example #1
0
 /**
  * Return element as XML string.
  *
  * @return string The element as XML string.
  * @throws XMLException if the element isn't a child of a DOMDocument.
  */
 public function toXML()
 {
     if ($this->ownerDocument === null) {
         throw new XMLException('XMLElement has no owner document');
     }
     return $this->ownerDocument->saveXML($this);
 }
Example #2
0
 /**
  * Test with the `ArrayAccess` interface if an attribute can be unset.
  */
 public function testOffsetUnset()
 {
     $doc = new XMLDocument();
     $config = $doc->root('config');
     $config['attr'] = true;
     unset($config['attr']);
     $this->assertFalse(isset($config['attr']));
 }
Example #3
0
 /**
  * Test if the `toString` method returns a node value as string.
  */
 public function testToStringReturnsStringValue()
 {
     $doc = new XMLDocument();
     $doc->root('config')->attribute('email', '*****@*****.**');
     $this->assertSame('*****@*****.**', $doc('#/config/@email')->toString());
 }