getElementsByTagName("root"); foreach($root as $roots){ echo $roots->getElementsByTagName("author")->item(0).nodeValue; }
我把这个问题提交到bug.php了。。反正暂时我就用3楼的方法解决了。 php给我回了封信。 ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/bug.php?id=53314&edit=2 ID: 53314 Updated by: [email protected] Reported by: 122363686 at qq dot com Summary: simplexml_load_string can't parse all tags -Status: Open +Status: Bogus Type: Bug Package: SimpleXML related Operating System: windows XP PHP Version: 5.3.3 Block user comment: N New Comment:Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.phpThis is a known detail when printing the SimpleXMLElement using print_r(). But the element is there.You can check them using:var_dump($xml->xpath('//textEntryInteraction'));There are others reported related to this, e.g. bug #44973But this is not a PHP bug, thanks.
$doc->load($file); //$file表示XML文件的路径 建议将XML与PHP放在同一个文件夹,然后$file直接写XML文件的文件名即可
$doc->formatOutput = true;
$Themes = $doc->documentElement->getElementsByTagName('item');//找到所有的item节点
$Theme = $Themes->item(0);//找到第一个item节点
$data = $Theme->nodeValue; // 找到该节点的内容。
以此类推就可以查找出你想要的每一个节点的内容,剩下的我就不多写了。
foreach($root as $roots){
echo $roots->getElementsByTagName("author")->item(0).nodeValue;
}
php给我回了封信。
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at
http://bugs.php.net/bug.php?id=53314&edit=2 ID: 53314
Updated by: [email protected]
Reported by: 122363686 at qq dot com
Summary: simplexml_load_string can't parse all tags
-Status: Open
+Status: Bogus
Type: Bug
Package: SimpleXML related
Operating System: windows XP
PHP Version: 5.3.3
Block user comment: N New Comment:Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.phpThis is a known detail when printing the SimpleXMLElement using
print_r(). But the element is there.You can check them using:var_dump($xml->xpath('//textEntryInteraction'));There are others reported related to this, e.g. bug #44973But this is not a PHP bug, thanks.
(array)强转后 依旧没有那个标签 之前我试过