PHP getName()ฟังก์ชั่น
ตัวอย่าง
ส่งคืนชื่อขององค์ประกอบ XML และรายการย่อย:
<?php
$xml=<<<XML
<?xml version="1.0" standalone="yes"?>
<cars>
<car id="1">Volvo</car>
<car id="2">BMW</car>
<car id="3">Saab</car>
</cars>
XML;
$sxe=new SimpleXMLElement($xml);
// Get the name of the cars element
echo $sxe->getName() . "<br>";
// Also print out the names of the children of the cars element
foreach ($sxe->children() as $child)
{
echo $child->getName() . "<br>";
}
?>
ความหมายและการใช้งาน
ฟังก์ชัน getName() ส่งกลับชื่อขององค์ประกอบ XML
ไวยากรณ์
SimpleXMLElement::getName()
รายละเอียดทางเทคนิค
คืนมูลค่า: | ชื่อขององค์ประกอบ XML เป็นสตริง |
---|---|
รุ่น PHP: | 5.1.3+ |
❮ การอ้างอิง PHP SimpleXML