PHP - Re-sorging XML doc with XSL
Posted: Tue Feb 05, 2008 11:45 am
hi all,
im using xpath to return some search results as an XML DOM. Now i need to implement a sorting function which would take any number of parameters and sort the results based on them.
Essentially the parameters will be tags in the xml docs like "Name" and "category" for now.
So heres an example of an output from my search
<data>
<block>
<name>Test Name 2</name>
<category>Category 2</category>
</block>
<block>
<name>a Simple test</name>
<category>Category 1</category
</block>
</data>
So if that was returned we can see that block 2 with the name "a simple test" is in position 2. I want to apply a sort that will move that into position one and return a new xml doc. I read how to transform XML with XSL and understand how to replace nodes and values, but lost trying to understand how to apply any kind of sorting.
Any help would be appreciated.
TIA,
mcm
im using xpath to return some search results as an XML DOM. Now i need to implement a sorting function which would take any number of parameters and sort the results based on them.
Essentially the parameters will be tags in the xml docs like "Name" and "category" for now.
So heres an example of an output from my search
<data>
<block>
<name>Test Name 2</name>
<category>Category 2</category>
</block>
<block>
<name>a Simple test</name>
<category>Category 1</category
</block>
</data>
So if that was returned we can see that block 2 with the name "a simple test" is in position 2. I want to apply a sort that will move that into position one and return a new xml doc. I read how to transform XML with XSL and understand how to replace nodes and values, but lost trying to understand how to apply any kind of sorting.
Any help would be appreciated.
TIA,
mcm