0
我的計劃是這樣的XML列表:嘗試讀取XML文件中的變量在PHP
<plans>
<plan>
<name>LITE</name>
<description>description</description>
<rate>$9/Month</rate>
<price>5</price>
<period>1</period>
<units>MONTH</units>
<recurring>1</recurring>
<acl>2</acl>
</plan>
<plan>
<name>PRO</name>
<description>description</description>
<rate>$10/Year</rate>
<price>5</price>
<period>1</period>
<units>YEAR</units>
<recurring>0</recurring>
<acl>3</acl>
</plan>
</plans>
但我不知道如何解析出「期」和「單位」 PARAMS。我正在嘗試這樣做,但我認爲出現了問題 - 就像我沒有正確處理DOM。
//$plan is already set above.
$plans_xml = simplexml_load_file("../plans.xml");
foreach ($plans_xml->plan->name as $item){
//if the plan in the xml matches the plan the user signed up for
if ($item == $plan){
//set interval by concatenating period and units
$interval = ($plans_xml->plan->period . $plans_xml->plan->units);
}
}