使用php从xml对基于国家的记录进行排序

时间:2013-06-29 09:25:44

标签: php xml sorting

我有一个excelsheet我写数据并将其导出到xml数据并获得xml格式如下现在我使用php usign解析此记录下面的代码但我有一个国家/地区下拉列表我想根据所选国家/地区显示此记录显示我使用php下拉获得的记录,但由于没有父子关系,我可以这样做,所以有没有办法这样做?

 <Row>
    <Cell><Data ss:Type="String">Dr. nair</Data></Cell>
    <Cell><Data ss:Type="String">12121 brok Blvd. </Data></Cell>
    <Cell><Data ss:Type="String">WEST INDIES</Data></Cell>
    <Cell><Data ss:Type="String">WI</Data></Cell>
    <Cell><Data ss:Type="Number">90025</Data></Cell>
    <Cell><Data ss:Type="String">310-444-1212</Data></Cell>
   </Row>

   <Row>
    <Cell><Data ss:Type="String">Dr. july</Data></Cell>
    <Cell><Data ss:Type="String">Paldi. </Data></Cell>
    <Cell><Data ss:Type="String">WEST INDIES</Data></Cell>
    <Cell><Data ss:Type="String">WI</Data></Cell>
    <Cell><Data ss:Type="Number">90025</Data></Cell>
    <Cell><Data ss:Type="String">310-4544-1212</Data></Cell>
   </Row>


    <Row>
    <Cell><Data ss:Type="String">Dr. lol</Data></Cell>
    <Cell><Data ss:Type="String">Paldi. </Data></Cell>
    <Cell><Data ss:Type="String">New Zeland</Data></Cell>
    <Cell><Data ss:Type="String">NZ</Data></Cell>
    <Cell><Data ss:Type="Number">90025</Data></Cell>
    <Cell><Data ss:Type="String">310-4544-1212</Data></Cell>
   </Row>


    <Row>
    <Cell><Data ss:Type="String">Dr. nik</Data></Cell>
    <Cell><Data ss:Type="String">Paldi. </Data></Cell>
    <Cell><Data ss:Type="String">India</Data></Cell>
    <Cell><Data ss:Type="String">IN</Data></Cell>
    <Cell><Data ss:Type="Number">90025</Data></Cell>
    <Cell><Data ss:Type="String">310-4544-1212</Data></Cell>
   </Row>



 $excel = new XML2003Parser('sample.xml');

    $table = $excel->getTableData();

    // display instruction

    echo "<table border=1>";

    $data=array();
    $data_city=array();
     foreach($table["table_contents"] as $row){

          $data[]=$row['row_contents'][3]['value'];
                  $data_city[]=$row['row_contents'][2]['value'];

        print_r($data);

    }  

0 个答案:

没有答案