Updated info:
Previously, I asked how to sort XML based on several attributes of each element. The answer there was valid (which is why I am creating a new question), but I found that I am under restrictions where my version of PHP does not have the XSLT library installed, and my IT will not install it.
I found a way to make my XML an associative array, but that seems really tedious to sort through.
Also, I have several levels of sorting (around 6); since there are so many, I cannot implement the other answer below.
So, my final question is: is it possible to sort an XML without using XSLT? Every time I Google it, all the sites show how to use XSLT...
Thanks again, everyone!
OLD INFO::::::I've done a whole bunch of research between DOM and XSL and can't seem to find a way to sort on multiple elements. I've successfully generated my XML using DOM, but now I would like to sort based on multiple values.
I would prefer to have another child under the <item> perhaps titled <Priority>, or I could put it in the <item priority=__>
For simplicity, here is a dumbed down version of what I am trying to do:
XML beforehand:
<root>
<item>
<attr1>2</attr1>
<attr2>50</attr2>
</item>
<item>
<attr1>1</attr1>
<attr2>100</attr2>
</item>
<item>
<attr1>2</attr1>
<attr2>10</attr2>
</item>
<item>
<attr1>2</attr1>
<attr2>50</attr2>
</item>
<item>
<attr1>1</attr1>
<attr2>75</attr2>
</item>
<item>
<attr1>2</attr1>
<attr2>1</attr2>
</item>
</root>
I'd like to find a way to make sort first on attr1, and if they're the same, then sort on attr2. As I said before, I don't care how I sort, nor do I care if we use the attribute within an element like <item priority = ___>, a new element for each <item>, or an entirely new xml file. I am just so lost as to what I should do next; I've been using PHP up to this point, but could switch to something else. Thanks in advance!