public function rootMember() { with($t = new Tree('formresult'), $r = $t->root()); $this->assertClass($r, 'xml.Node'); $this->assertFalse($r->hasChildren()); $this->assertEmpty($r->getAttributes()); $this->assertEquals('formresult', $r->getName()); }
public function rootMember() { with($t = new Tree('formresult'), $r = $t->root()); $this->assertInstanceOf(Node::class, $r); $this->assertFalse($r->hasChildren()); $this->assertEquals([], $r->getAttributes()); $this->assertEquals('formresult', $r->getName()); }
/** * Returns an XML tree for use in further test cases * * @return xml.Tree */ protected function personTree() { $t = new Tree('person'); $t->root()->setAttribute('id', '1549'); $t->addChild(new \xml\Node('firstName', 'Timm')); $t->addChild(new \xml\Node('lastName', 'Friebe')); $t->addChild(new \xml\Node('location', 'Karlsruhe')); $t->addChild(new \xml\Node('location', 'Germany')); return $t; }
/** * Marshal an object to xml * * @param lang.Object instance * @param xml.QName qname default NULL * @return string xml * @deprecated Use marshalTo() instead */ public static function marshal($instance, $qname = null) { $class = $instance->getClass(); // Create XML tree and root node. Use the information provided by the // qname argument if existant, use the class` non-qualified (and // lowercased) name otherwise. $tree = new Tree(); if ($qname) { $prefix = $qname->prefix ? $qname->prefix : $qname->localpart[0]; $tree->root()->setName($prefix . ':' . $qname->localpart); $tree->root()->setAttribute('xmlns:' . $prefix, $qname->namespace); } else { if ($class->hasAnnotation('xmlns')) { $tree->root()->setName($class->getSimpleName()); } else { $tree->root()->setName(strtolower($class->getSimpleName())); } } self::recurse($instance, $class, $tree->root(), []); return $tree->getSource(INDENT_DEFAULT); }