【发布时间】:2023-03-21 16:00:01
【问题描述】:
您好,我有一段 XML 输出包含
<Question type="2" text="Which one of the following area codes is associated with you?">
<Answer correct="false">606</Answer>
<Answer correct="false">859</Answer>
<Answer correct="false">616</Answer>
<Answer correct="false">614/380</Answer>
<Answer correct="false">812</Answer>
<Answer correct="true">502</Answer>
<Answer correct="false">810</Answer>
<Answer correct="false">740</Answer>
<Answer correct="false">248</Answer>
<Answer correct="false">None of the above</Answer>
</Question>
我正在使用它来解析响应
$objXmlDocument = simplexml_load_string($response,null,LIBXML_NOCDATA);
if ($objXmlDocument === FALSE) {
echo "There were errors parsing the XML file.\n";
foreach(libxml_get_errors() as $error) {
echo $error->message;
}
exit;
}
$objJsonDocument = json_encode($objXmlDocument);
$arrOutput = json_decode($objJsonDocument,TRUE);
返回结果时,我得到了问题的类型,但没有得到正确的值字段。是因为结构的深度吗?
【问题讨论】: