本文整理匯總了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);
}