0

我有一个这样的计划的 xml 列表:

<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>

但我不确定如何解析“句点”和“单位”参数。我正在尝试这样,但我认为有问题 - 就像我没有正确处理 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);
        }
    }
4

1 回答 1

0
foreach ($plans_xml->plan as $item){
    var_dump( $item->name );
}

给,精简版专业版

那么你可以做你的条件检查

于 2013-03-30T11:16:58.010 回答