APIから次のXML出力があります
<?xml version='1.0' encoding='UTF-8'?>
<Response>
<ReturnRow Output1="11" Output2="12" Output3="13" Output4="14" Output5="15" />
<ReturnRow Output1="21" Output2="22" Output3="23" Output4="24" Output5="25" />
<Messages>
<Message Code="INFO" Msg="Your request is successful." Type="APP"/>
</Messages>
</Response>
PHPを使用して上記のxmlを解析し、子要素をループして、HTMLテーブルにReturnRown
エコーアウトしようとしています。Output1
Output2
現在の私のコードは次のとおりです。
$doc = new DOMDocument();
$doc->loadXML($test); //$test is holding the above XML
$node = $doc->getElementsByTagName( "ReturnRow" );
foreach ($node as $book) {
var_dump($book);
}
しかし、上記は実際にはOuput1
、Output2
などの値を私に与えていません。
私は何が欠けているか、間違っていますか?
上記のPHPコードの結果:
object(DOMElement)#3 (18) { ["tagName"]=> string(9) "ReturnRow" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(9) "ReturnRow" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(9) "ReturnRow" ["baseURI"]=> string(20) "file:///W:/ischools/" ["textContent"]=> string(0) "" } object(DOMElement)#5 (18) { ["tagName"]=> string(9) "ReturnRow" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(9) "ReturnRow" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(9) "ReturnRow" ["baseURI"]=> string(20) "file:///W:/ischools/" ["textContent"]=> string(0) "" }