내 PHP 간단한 XML 개체에 문제가 있습니다.xml to php 배열 문제
나는이 내 로그에 다음과 같은 XML 데이터
SimpleXMLElement Object
(
[@attributes] => Array
(
[title] => test
[scanner] => Data
[id] => WordData
[position] => 1800
[error] => false
[num] => 6
)
[subpod] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[title] => Surnames
)
[plaintext] => Common (US population: 650 people, white: 63% | black: 35%)
[img] => SimpleXMLElement Object
(
[@attributes] => Array
(
[alt] => Common (US population: 650 people, white: 63% | black: 35%)
[title] => Common (US population: 650 people, white: 63% | black: 35%)
[width] => 349
[height] => 18
)
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[title] => Cities
)
[plaintext] => Littleton Common (Massachusetts, 2789 people)
[img] => SimpleXMLElement Object
(
[@attributes] => Array
(
[alt] => Littleton Common (Massachusetts, 2789 people)
[title] => Littleton Common (Massachusetts, 2789 people)
[width] => 287
[height] => 18
)
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[title] => Buildings
)
[plaintext] => Rotunda on Woolwich Common (London, Greater London)
[img] => SimpleXMLElement Object
(
[@attributes] => Array
(
[alt] => Rotunda on Woolwich Common (London, Greater London)
[title] => Rotunda on Woolwich Common (London, Greater London)
[width] => 356
[height] => 18
)
)
)
.....more simpleXmlElement object
)
)
내 PHP는 varible $xmlObj = SimpleXMLElement Object
하지만이 때
if (is_array($xmlObj->subpod)){
echo 'is array';
}else {
echo 'not array';
}
출력이 '하지 배열'항상 내가 내 코드를 원하는 다음 에코 '는 배열입니다'
나는 $xmlObj->subpod
이 배열이라고 생각했습니다. $xmlObj->subpod[0]->plaintext
을 테스트하면 실제로 문자열이 반환됩니다. 이 문제를 해결하는 방법을 모르겠습니다. 누구든지 도와 줄 수 있습니까?
'var_dump ($ xmlObj-> subpod); – AlienWebguy
따옴표를 사용하는 사람은 어디에 있습니까? –