當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。