
SimpleXMLElement::current를 사용하여 XML 요소를 반복 처리 할 때, 이 함수를 사용한 후 다음 요소를 얻기 위해 SimpleXMLElement::next를 사용해야 합니다.
이러한 방법으로 다음 요소를 얻을 수 있습니다.
#hostingforum.kr
php
$xml = new SimpleXMLElement('John30');
$element = $xml->xpath('//name');
echo $element[0]->asXML(); // John
echo $element[0]->next()->asXML(); // 30
또는 foreach 문을 사용하여 반복 처리 할 수 있습니다.
#hostingforum.kr
php
$xml = new SimpleXMLElement('John30');
foreach ($xml->xpath('//name') as $element) {
echo $element->asXML(); // John
echo $element->next()->asXML(); // 30
}
이러한 방법으로 XML 요소를 반복 처리 할 수 있습니다.
2025-08-11 14:50