After I load an XML file, can I sort it by node attribute

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bissatch@yahoo.co.uk

    After I load an XML file, can I sort it by node attribute

    Hi,

    After loading an xml file, is it possible to sort it by attribute?

    For example, I have the following xml file:


    <xml...
    <diary>
    <entry date="2005-01-01">I went to the park</entry>
    <entry date="2005-01-03">Sold the car today</entry>
    <entry date="2005-01-02">Went for a stroll</entry>
    </diary>


    When I go to load this using PHP, I would use some this similar to
    this:


    $xmldoc = domxml_open_fil e('diary.xml', DOMXML_LOAD_DON T_KEEP_BLANKS);

    $node = $xmldoc->document_eleme nt();


    Before I go storming through the xml tree outputing along the way, can
    I sort it by (in this case) date?

    Cheers

    Burnsy

  • Tim Van Wassenhove

    #2
    Re: After I load an XML file, can I sort it by node attribute

    On 2005-08-17, bissatch@yahoo. co.uk <bissatch@yahoo .co.uk> wrote:[color=blue]
    > After loading an xml file, is it possible to sort it by attribute?[/color]

    Why don't you perform a XSLT with <xsl:for-each order-by> ?

    Another option could be to use parse_into_stru ct and then use of the
    array_sort methods?

    --
    Met vriendelijke groeten,
    Tim Van Wassenhove <http://timvw.madoka.be >

    Comment

    Working...