SimpleXML PHP按字母顺序排序

时间:2015-11-10 11:17:52

标签: php simplexml

我想知道一种使用SimpleXML PHP按字母顺序对XML节点进行排序然后分组显示的方法。

XML的示例

                          
                其他一些节点                      

    <event classId="115" displayClassId="" typeId="2343" displayTypeId="" typeName="Euro 2016 Play-Offs" id="3308166" displayOrder="0" name="Bosnia v Rep. Ireland" url="/e/3308166" date="2015-11-13" time="19:45:00" betTillDate="2015-11-13" betTillTime="19:45:00" suspend="" sort="MTCH" status="A" channels="IPCMQG" country="" raceNumber="" flags=",T27" lastUpdateDate="2015-11-10" lastUpdateTime="">
        <market id="65460043" displayOrder="-500" name="Match Result" type="-" sort="MR" status="A" birIndex="" unformattedHandicap="" handicap="" placeAvailable="N" forecastAvailable="N" tricastAvailable="N" eachwayAvailable="N" startingPriceAvailable="N" livePriceAvailable="Y" guarenteedPriceAvailable="N" channels="IPCMQG" url="/m/65460043" lastUpdateDate="2015-10-18" lastUpdateTime="16:24:54" isRestricted="N">
            Some other Nodes
        </market>
    </event>

    <event classId="115" displayClassId="" typeId="2343" displayTypeId="" typeName="Euro 2016 Play-Offs" id="3308169" displayOrder="0" name="Ukraine v Slovenia" url="/e/3308169" date="2015-11-14" time="17:00:00" betTillDate="2015-11-14" betTillTime="17:00:00" suspend="" sort="MTCH" status="A" channels="IPCMQG" country="" raceNumber="" flags=",T27" lastUpdateDate="2015-11-09" lastUpdateTime="">
        <market id="65460394" displayOrder="-500" name="Match Result" type="-" sort="MR" status="A" birIndex="" unformattedHandicap="" handicap="" placeAvailable="N" forecastAvailable="N" tricastAvailable="N" eachwayAvailable="N" startingPriceAvailable="N" livePriceAvailable="Y" guarenteedPriceAvailable="N" channels="IPCMQG" url="/m/65460394" lastUpdateDate="2015-10-18" lastUpdateTime="16:24:53" isRestricted="N">
            Some other Nodes
        </market>
    </event>

    <event classId="120" displayClassId="" typeId="734" displayTypeId="" typeName="Italian Serie A" id="3335762" displayOrder="0" name="Bologna v Roma" url="/e/3335762" date="2015-11-21" time="17:00:00" betTillDate="2015-11-21" betTillTime="17:00:00" suspend="" sort="MTCH" status="A" channels="CGIMPQ" country="" raceNumber="" flags=",,,ST,,,,,,,,,,T37" lastUpdateDate="2015-11-04" lastUpdateTime="">
        <market id="66678954" displayOrder="-500" name="Match Result" type="-" sort="MR" status="A" birIndex="" unformattedHandicap="" handicap="" placeAvailable="N" forecastAvailable="N" tricastAvailable="N" eachwayAvailable="N" startingPriceAvailable="N" livePriceAvailable="Y" guarenteedPriceAvailable="N" channels="IPCMQG" url="/m/66678954" lastUpdateDate="2015-11-04" lastUpdateTime="16:03:06" isRestricted="N">
            Some other Nodes
        </market>
    </event>
    <event classId="120" displayClassId="" typeId="734" displayTypeId="" typeName="Italian Serie A" id="3335757" displayOrder="0" name="Juventus v AC Milan" url="/e/3335757" date="2015-11-21" time="19:45:00" betTillDate="2015-11-21" betTillTime="19:45:00" suspend="" sort="MTCH" status="A" channels="CGIMPQ" country="" raceNumber="" flags=",,,ST,,,,,,,,,,T36" lastUpdateDate="2015-11-04" lastUpdateTime="">
        <market id="66678442" displayOrder="-500" name="Match Result" type="-" sort="MR" status="A" birIndex="" unformattedHandicap="" handicap="" placeAvailable="N" forecastAvailable="N" tricastAvailable="N" eachwayAvailable="N" startingPriceAvailable="N" livePriceAvailable="Y" guarenteedPriceAvailable="N" channels="IPCMQG" url="/m/66678442" lastUpdateDate="2015-11-04" lastUpdateTime="16:03:16" isRestricted="N">
            Some other Nodes
        </market>
    </event>
    <event classId="166" displayClassId="" typeId="971" displayTypeId="" typeName="Spanish La Liga" id="3359006" displayOrder="0" name="Valencia v Las Palmas" url="/e/3359006" date="2015-11-21" time="21:00:00" betTillDate="2015-11-21" betTillTime="21:00:00" suspend="" sort="MTCH" status="A" channels="CGIMPQ" country="" raceNumber="" flags=",,,ST,,,,,,,,,,T28" lastUpdateDate="2015-11-09" lastUpdateTime="">
        <market id="67650588" displayOrder="-500" name="Match Result" type="-" sort="MR" status="A" birIndex="" unformattedHandicap="" handicap="" placeAvailable="N" forecastAvailable="N" tricastAvailable="N" eachwayAvailable="N" startingPriceAvailable="N" livePriceAvailable="Y" guarenteedPriceAvailable="N" channels="IPCMQG" url="/m/67650588" lastUpdateDate="2015-11-09" lastUpdateTime="10:49:01" isRestricted="N">
            Some other Nodes

        </market>
    </event>

AND SO ON.....

我想使用要显示的事件节点和组的typeName属性按字母顺序排序。

这可能吗?

0 个答案:

没有答案
相关问题