我的最終解決方案:
$res = $xpath->query("//form//div/@xmltag"); // OBS: xmltag not xmlTag
$total_fields = $res->length;
for ($i = 1; $i <= $total_fields; $i ++)
{
$r = $xpath->query("//form//div[$i]/@xmltag");
$xmltag = $r->item(0)->value;
$r = $xpath->query("//form//div[$i]/@controltype");
$controltype = $r->item(0)->value;
$div[$i - 1] = array(
'xmltag' => $xmltag,
'controltype' => $controltype
);
}
輸出樣本:
array (
0 =>
array (
'xmltag' => 'Case_Number',
'controltype' => '',
),
1 =>
array (
'xmltag' => 'Plaintiff',
'controltype' => 'RadioButtons',
),
2 =>
array (
'xmltag' => 'Plaintiff_Name',
'controltype' => '',
),
美麗!
你是認真的嗎?我問一個基於PHP的解決方案,而不是JavaScript!任何方式看起來不錯。 –