Watch 1 Star 0 Fork 2

sunboy2050 / mimvp-sitemap-phpPHPMIT

forked from mimvp / mimvp-sitemap-php 
Sign up for free
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
Clone or download
test_xml_read.php 857 Bytes
Copy Edit Web IDE Raw Blame History
homer authored 2017-08-08 22:12 . commit mimvp-sitemap-php
<?php
/**
* mimvp.com
* 2017.06.22
*/
header ( "Content-type: text/html; charset=utf-8" );
$xml = new XMLReader ();
// 载入xml文件,如果是字符串直接使用xml方法
$xml->open ( "mimvp.xml" );
// 开始读取xml
while ( $xml->read () ) {
// 根据节点类型和元素名称取得文本节点或属性
if ($xml->nodeType == XMLREADER::ELEMENT && $xml->localName == 'item') {
print $xml->getAttribute ( "info" ) . "</br>";
}
if ($xml->nodeType == XMLREADER::ELEMENT && $xml->localName == 'id') {
$xml->read (); // 移动指针到下一个节点
print $xml->value . "\t";
}
if ($xml->nodeType == XMLREADER::ELEMENT && $xml->localName == 'name') {
$xml->read ();
print $xml->value . "</br>";
}
if ($xml->nodeType == XMLREADER::ELEMENT && $xml->localName == 'age') {
$xml->read ();
print $xml->value . "</br>";
}
}
?>

Comment ( 0 )

You need to Sign in for post a comment

Help Search