0
를 소문자로 나는 XML로이있어 $testcase
소문자 형식 (defaultimage) 그러나 XML 파일에서 자식 이름은 defaultImage
입니다 (대문자 I 참고)PHP의 SimpleXML을 어린이
질문 : 어떻게 모든 어린이를 소문자로 처리 할 수 있습니까?
를 소문자로 나는 XML로이있어 $testcase
소문자 형식 (defaultimage) 그러나 XML 파일에서 자식 이름은 defaultImage
입니다 (대문자 I 참고)PHP의 SimpleXML을 어린이
질문 : 어떻게 모든 어린이를 소문자로 처리 할 수 있습니까?
->children()
배열을 반복하면서 ->getName()
메서드를 사용하면 노드 이름을 찾을 수 있습니다.
는 명확하게하기 위해, 나는 외부 루프
$testcase = 'defaultimage';
$xml = simplexml_load_file('./temp/'.$i.'.xml');
foreach ($xml->product as $product)
{
foreach ($product->children as $child)
{
if (strtolower($child->getName()) == $testcase)
{
// Do whatever it is you need to do with the <defaultImage> node
}
}
}
모든
product
노드를 통해 더 명시 적 루프를 사용했습니다