本文整理汇总了PHP中XMLReader::Xml方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLReader::Xml方法的具体用法?PHP XMLReader::Xml怎么用?PHP XMLReader::Xml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLReader
的用法示例。
在下文中一共展示了XMLReader::Xml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testMoveToClosingElementWithSelfClosingTag
/**
* Tests JFeedParser::moveToClosingElement() with self-closing tags.
*
* @return void
*
* @since 12.3
*/
public function testMoveToClosingElementWithSelfClosingTag()
{
// Set the XML for the internal reader and move the stream to the first <node> element.
$this->_reader->Xml('<root><node test="first" /><node test="second"></node></root>');
// Advance the reader to the first <node> element.
do {
$this->_reader->read();
} while ($this->_reader->name != 'node');
// Ensure that the current node is <node test="first">.
$this->assertEquals(XMLReader::ELEMENT, $this->_reader->nodeType);
$this->assertEquals('node', $this->_reader->name);
$this->assertEquals('first', $this->_reader->getAttribute('test'));
// Move to the closing element, which should be </node>.
TestReflection::invoke($this->_instance, 'moveToClosingElement');
$this->assertEquals(true, $this->_reader->isEmptyElement);
$this->assertEquals('node', $this->_reader->name);
// Advance the reader to the next element.
do {
$this->_reader->read();
} while ($this->_reader->nodeType != XMLReader::ELEMENT);
// Ensure that the current node is <node test="first">.
$this->assertEquals(XMLReader::ELEMENT, $this->_reader->nodeType);
$this->assertEquals('node', $this->_reader->name);
$this->assertEquals('second', $this->_reader->getAttribute('test'));
}
示例2: testInitialise
/**
* Tests JFeedParserRss::initialise()
*
* @param string $expected The expected rss version string.
* @param string $xml The XML string for which to detect the version.
*
* @return void
*
* @dataProvider seedInitialise
* @since 12.3
*/
public function testInitialise($expected, $xml)
{
// Set the XML for the internal reader.
$this->_reader->Xml($xml);
// Advance the reader to the first element.
do {
$this->_reader->read();
} while ($this->_reader->nodeType != XMLReader::ELEMENT);
TestReflection::invoke($this->_instance, 'initialise');
$this->assertAttributeEquals($expected, 'version', $this->_instance, 'The version string detected should match the expected value.');
// Verify that after detecting the version we are ready to start parsing.
$this->assertEquals('test', $this->_reader->name);
$this->assertEquals(XMLReader::ELEMENT, $this->_reader->nodeType);
}