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


PHP XMLReader::Xml方法代码示例

本文整理汇总了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'));
 }
开发者ID:n3t,项目名称:joomla-cms,代码行数:32,代码来源:JFeedParserTest.php

示例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);
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:25,代码来源:JFeedParserRssTest.php


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