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 참조