当前位置: 首页>>代码示例>>PHP>>正文


PHP Reader::parse方法代码示例

本文整理汇总了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);
}
开发者ID:igorw,项目名称:ilias,代码行数:9,代码来源:macro-expand.php

示例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);
    }
开发者ID:sebbie42,项目名称:casebox,代码行数:17,代码来源:InfiteLoopTest.php

示例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());
    }
开发者ID:mauris,项目名称:htmlmeta,代码行数:14,代码来源:ReaderTest.php

示例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);
    }
开发者ID:russellgalpin,项目名称:sabre-xml,代码行数:26,代码来源:ReaderTest.php

示例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();
    }
开发者ID:kalmas,项目名称:sabre-xml,代码行数:17,代码来源:ReaderTest.php


注:本文中的Reader::parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。