本文整理汇总了PHP中Reader::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP Reader::parse方法的具体用法?PHP Reader::parse怎么用?PHP Reader::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reader
的用法示例。
在下文中一共展示了Reader::parse方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForms
function buildForms($code)
{
$lexer = new Lexer();
$reader = new Reader();
$builder = new FormTreeBuilder();
$tokens = $lexer->tokenize($code);
$ast = $reader->parse($tokens);
return $builder->parseAst($ast);
}
示例2: testDeserialize
/**
* This particular xml body caused the parser to go into an infinite loop.
* Need to know why.
*/
function testDeserialize()
{
$body = '<?xml version="1.0"?>
<d:propertyupdate xmlns:d="DAV:" xmlns:s="http://sabredav.org/NS/test">
<d:set><d:prop></d:prop></d:set>
<d:set><d:prop></d:prop></d:set>
</d:propertyupdate>';
$reader = new Reader();
$reader->elementMap = ['{DAV:}set' => 'Sabre\\Xml\\Element\\KeyValue'];
$reader->xml($body);
$output = $reader->parse();
$this->assertEquals(['name' => '{DAV:}propertyupdate', 'value' => [['name' => '{DAV:}set', 'value' => ['{DAV:}prop' => null], 'attributes' => []], ['name' => '{DAV:}set', 'value' => ['{DAV:}prop' => null], 'attributes' => []]], 'attributes' => []], $output);
}
示例3: testParse
public function testParse()
{
$reader = new Reader();
$content = <<<EOT
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
EOT;
$result = $reader->parse($content);
$this->assertCount(4, $result);
$this->assertEquals(array('property' => 'og:title', 'content' => 'The Rock'), $result[0]->attributes());
$this->assertEquals(array('property' => 'og:type', 'content' => 'video.movie'), $result[1]->attributes());
}
示例4: testParseInnerTree
/**
* @depends testMappedElement
*/
function testParseInnerTree()
{
$input = <<<BLA
<?xml version="1.0"?>
<root xmlns="http://sabredav.org/ns">
<elem1>
<elem1 />
</elem1>
</root>
BLA;
$reader = new Reader();
$reader->elementMap = ['{http://sabredav.org/ns}elem1' => function (Reader $reader) {
$innerTree = $reader->parseInnerTree(['{http://sabredav.org/ns}elem1' => function (Reader $reader) {
$reader->next();
return "foobar";
}]);
return $innerTree;
}];
$reader->xml($input);
$output = $reader->parse();
$expected = ['name' => '{http://sabredav.org/ns}root', 'value' => [['name' => '{http://sabredav.org/ns}elem1', 'value' => [['name' => '{http://sabredav.org/ns}elem1', 'value' => 'foobar', 'attributes' => []]], 'attributes' => []]], 'attributes' => []];
$this->assertEquals($expected, $output);
}
示例5: testBrokenXML
/**
* Test was added for Issue #10.
*
* @expectedException Sabre\XML\LibXMLException
*/
function testBrokenXML()
{
$input = <<<BLA
<test>
<hello>
</hello>
</sffsdf>
BLA;
$reader = new Reader();
$reader->xml($input);
$reader->parse();
}