在php中按预定顺序显示xml中的数据

在php中按预定顺序显示xml中的数据,php,xml,Php,Xml,我还在学习如何用php处理xml数据 这是我上一个问题的第二部分 现在我需要能够根据“价格”标签以降序或升序显示项目 以下是迄今为止的代码: <?php $itm = $_GET['itm']; $ITEMSS = new SimpleXMLElement('items.xml', null, true); echo <<<EOF <table width="100%" align="center" border="1" bordercolor="#0099ff"

我还在学习如何用php处理xml数据

这是我上一个问题的第二部分

现在我需要能够根据“价格”标签以降序或升序显示项目

以下是迄今为止的代码:

<?php
$itm = $_GET['itm'];
$ITEMSS = new SimpleXMLElement('items.xml', null, true);

echo <<<EOF
<table width="100%" align="center" border="1" bordercolor="#0099ff" cellpadding="1" cellspacing="0">

<tr>
        <th bgcolor="#66ccff"><span class="style4">ITEM Name</span></th>
        <th bgcolor="#66ccff"><span class="style4">item TYPE </span></th>
        <th bgcolor="#66ccff"><span class="style4">item DESCIPTION </span></th>
        <th bgcolor="#66ccff"><span class="style4">item PRICE</span></th>
</tr>

EOF;
foreach($ITEMSS as $ITEMS) // loop through our DATAS
{
if($ITEMS->TITLE=="$itm")
{
    echo <<<EOF
    <tr height="30" align=middle>
        <td>{$ITEMS->TITLE}</td>
        <td>{$ITEMS->TYPE}</td>
        <td>{$ITEMS->DESCIPTION}</td>
        <td>{$ITEMS->PRICE}</td>
    </tr>

EOF;
}
}


echo '</table>';
?>

以下是xml树:

以下是我正在测试的页面:


检查:我试图理解,但在使用寻呼系统和排序数据时仍然存在问题