Example #1
0
 public function readNextItem()
 {
     $this->open();
     $available = $this->xmlParser->parseOne();
     if ($available) {
         return $this->lastResult;
     }
     return false;
 }
Example #2
0
 public function testDictionaryStrategy()
 {
     $hit = false;
     $parser = new XmlParser("cache/unit-test-xml-stream.xml");
     $parser->addNodeHandler("dictionary", new NodeStrategyCollationDictionary(function ($node) use(&$hit) {
         $hit = $node;
     }));
     $parser->parse();
     $this->assertEquals("George", $hit["name"]);
     $this->assertEquals("tall", $hit["height"]);
     $this->assertCount(4, $hit["children"]);
     $this->assertEquals("son", $hit["children"]["joe"]);
     $this->assertEquals("deal", $hit["children"]["big"]);
     $this->assertCount(3, $hit["interest"]);
     $this->assertEquals("Fishing", $hit["interest"][0]);
     $this->assertCount(2, $hit["interest"][2]["complexInterest"]);
     $this->assertEquals("Knitting", $hit["interest"][2]["complexInterest"][1]);
     $this->assertCount(3, $hit["word"]);
     $this->assertEquals("a", $hit["word"][0]["name"]);
 }