PHP100 is the first professional website in China to share PHP resources. It also provides a PHP Chinese communication community. For PHP study researchers: The latest PHP information, original content, open source code and PHP video tutorials and other related content. [Reading guide] the sorting function makes the data on our pages more user-friendly, which is a common function we have seen on our websites. In the past, automatic sorting was completed with a large amount of script code, which is difficult for general enthusiasts. However, xml is much easier to process. Let
The sorting function makes the data on our pages more user-friendly, which is a common function we have seen on our websites. In the past, automatic sorting was completed with a large amount of script code, which is difficult for general enthusiasts. However, xml is much easier to process. Make your pages more beautiful. haha, are you also excited!
Materials:
Dynamic sorting of XML volumes
There are two files: paixu. xml and paixu. xsl.
Purpose:
Without refreshing a new page, you can sort and display the data based on your needs. this effectively improves the data interaction function and makes your pages more colorful.
Effect:
Browse here
Code:
Paixu. xml
1
Sailflying
A simple sorting
2002-1-11 17:35:33
XML topics
2
Flyingbird
Marry you. it hurts you.
2001-09-06 12:45:51
Irrigation essence
3
Accounts
Application of regular expressions in UBB forum
2001-11-23 21:02:16
Web Programming Essence
4
Taiyilang
End-of-year classic rudder gathering full manual v0.1
2000-12-08 10:22:48
Forum irrigation area
5
Mmkk
Asp error message summary
2001-10-13 16:39:05
Javascript script
Paixu. xsl
Practical tips for XML volumes (1): Dynamic sorting
Script function taxis (x) {stylesheet = document. optional document; source = document. XMLDocument; sortField = document. invalid document. selectSingleNode ("// @ order-by"); sortField. value = x; layer1.innerhtml#source.doc umentElement. transformNode (stylesheet);} script
Practical tips for XML volumes (1): Dynamic sorting
| No. |
Name |
Topic |
Posting time |
Category |
Explanation:
1) paixu. xml is a data file and we believe it will not be a problem.
2) paixu. xsl is a format file. pay attention to it in a few places.
(1) in the script:
SortField = document. document. selectSingleNode ("// @ order-");
The role is to find the first node with the order-by attribute, so the corresponding node is
Therefore, during the first onLoad, the value of order-by is blue_ID.
We re-define the value of order-by to sort the order.
Layer1.innerhtml#source.doc umentElement. transformNode (stylesheet );
The role is to change Layer1 after the XML data is converted. Therefore, after the 'Blue _ name' parameter is passed out,
Name
We change the value of order-by to 'Blue _ name', that is, 'Blue _ name' as the sorting method.
Then, the new sorting content is displayed by re-displaying the innerHTML value of Layer1.
(2) text:
Order-
This is not enough, or we won't be able to find it. let's take a look !!
Another point:
The code displayed in most XML textbooks rarely includes encoding = "gb2312 ",
Therefore, when we use Chinese in XML, an error is reported because this statement is not written.
Postscript:
After you are familiar with the dynamic sorting idea, you will find that our implementation method is very simple.
Is to modify the value of order-by, and then re-display.
We still follow this idea in the dynamic query and dynamic paging functions.
The above is the first volume of XML practices: detailed content of dynamic sorting. For more information, see other related articles in the first PHP community!