本文整理汇总了PHP中Reader::xml方法的典型用法代码示例。如果您正苦于以下问题:PHP Reader::xml方法的具体用法?PHP Reader::xml怎么用?PHP Reader::xml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reader
的用法示例。
在下文中一共展示了Reader::xml方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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();
}