PHP getName() º¯Êý
¶¨ÒåºÍÓ÷¨
getName() º¯Êý´Ó SimpleXMLElement ¶ÔÏó»ñÈ¡ XML ÔªËØµÄÃû³Æ¡£
Èç¹û³É¹¦£¬¸Ãº¯Êý·µ»Øµ±Ç°µÄ XML ÔªËØµÄÃû³Æ¡£Èç¹ûʧ°Ü£¬Ôò·µ»Ø false¡£
Óï·¨
class SimpleXMLElement
{
string getName()
}
Àý×Ó
XML Îļþ£º
<?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>George</to> <from>John</from> <heading>Reminder</heading> <b:body>Don't forget the meeting!</b:body> </note>
PHP ´úÂ룺
<?php
if (file_exists('test.xml'))
{
$xml = simplexml_load_file('test.xml');
}
echo $xml->getName();
foreach($xml->children() as $child)
{
echo $child->getName();
}
?>
Êä³öÀàËÆ£º
note to from heading body