public function testParseThings() { $xml = "<nons><a xmlns=\"foo#\" xmlns:b=\"b#\" b:r=\"b\" c=\"d\"><b:q uhm=\"wat\" b:e=\"f\"/>HHAI &<q /></a></nons>"; $n = new TOGoS_XMLRDFParser_XML_XMLNamespacifier($this); $p = new TOGoS_XMLRDFParser_XML_XMLParser($n); $p->parse($xml); $this->assertEquals(9, count($this->things)); $this->assertOpenTag($this->things[0], 'nons', array()); $this->assertOpenTag($this->things[1], 'foo#a', array('b#r' => 'b', 'foo#c' => 'd')); $this->assertOpenTag($this->things[2], 'b#q', array('foo#uhm' => 'wat', 'b#e' => 'f')); $this->assertCloseTag($this->things[3], 'b#q'); $this->assertEquals('HHAI &', $this->things[4]); $this->assertOpenTag($this->things[5], 'foo#q', array()); $this->assertCloseTag($this->things[6], 'foo#q'); $this->assertCloseTag($this->things[7], 'foo#a'); $this->assertCloseTag($this->things[8], 'nons'); }
public function testParseThings() { $xml = "<!--IGNORE-ME!-->標準萬國碼<tag>hi<xx:brag xmlns:xx=\"bag\" something=\"& "\"/></mag>"; $p = new TOGoS_XMLRDFParser_XML_XMLParser($this); $p->parse($xml); $this->assertEquals(6, count($this->things)); $this->assertEquals("標準萬國碼", $this->things[0]); $this->assertEquals('tag', $this->things[1][0]); $this->assertEquals(0, count($this->things[1][1])); $this->assertEquals('hi', $this->things[2]); $this->assertEquals('xx:brag', $this->things[3][0]); $this->assertEquals(2, count($this->things[3][1])); $this->assertEquals('bag', $this->things[3][1]['xmlns:xx']); $this->assertEquals('& "', $this->things[3][1]['something']); $this->assertEquals(array('xx:brag', 'closed'), $this->things[4]); $this->assertEquals(array('mag', 'closed'), $this->things[5]); }
/** * Convenience method so you don't have to make your own XMLParsers, etc */ public function parse($xml) { $namespacifier = new TOGoS_XMLRDFParser_XML_XMLNamespacifier($this); $xmlparser = new TOGoS_XMLRDFParser_XML_XMLParser($namespacifier); $xmlparser->parse($xml); return $this->getRootObject(); }