The sorting effect makes the data on our pages more user-friendly, which is a very broad consequence we have seen on our websites. In the past, active sorting was completed with a large number of script code, which is hard for general enthusiasts.
The sorting effect makes the data on our pages more user-friendly, which is a very broad consequence we have seen on our websites. In the past, active sorting was completed with a large number of script code, which is difficult for general enthusiasts. However, it is much simpler to use XML for processing. Make your pages even more magnificent. 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 own needs, effectively improving the data interaction function and making your pages more colorful.
Code:
Reference content is as follows:
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
Essence of water injection
3
Accounts
Use 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 water injection zone
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. document;
Source = document. XMLDocument;
SortField = document. document. selectSingleNode ("// @ order-");
SortField. value = x;
Layer1.innerhtml#source.doc umentElement. transformNode (stylesheet );
}
Script
Practical tips for XML volumes (1): Dynamic sorting
| No. |
Name |
Topic |
Posting time |
Return class |
Explanation:
1) paixu. xml is a data file, and you are not trusted to have a title.
2) paixu. xsl is a pattern file, there are several places to pay attention.
(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 achieve the sorting goal.
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
The value of order-by is changed to 'Blue _ name', that is, 'Blue _ name' is used 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. Otherwise, we won't be able to find it. what are the consequences? look at it!
Another point:
The code displayed in most XML textbooks rarely includes encoding = "gb2312 ",