public function testParseThings()
 {
     $xml = "<nons><a xmlns=\"foo#\" xmlns:b=\"b#\" b:r=\"b\" c=\"d\"><b:q uhm=\"wat\" b:e=\"f\"/>HHAI &amp;<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');
 }
示例#2
0
 public function testParseThings()
 {
     $xml = "<!--IGNORE-ME!-->&#x6A19;&#x6E96;&#x842C;&#x570B;&#x78BC;<tag>hi<xx:brag xmlns:xx=\"bag\" something=\"&amp; &quot;\"/></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]);
 }
示例#3
0
 /**
  * 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();
 }