Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of dynamic sorting in XML

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you the example analysis of dynamic sorting in XML, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The sorting function makes the data on our page more humane, which is a common feature we have seen on the website. In the past, automatic sorting is done with a lot of script code, which is a difficult thing for the average enthusiast. However, it is much easier to deal with it with xml. Make your page more gorgeous, , are you also moved?

Materials:

Dynamic sorting of XML volumes

There are two files: paixu.xml and paixu.xsl

Function:

In the case of not refreshing the page, the data will be re-sorted and displayed according to the needs of users, which can effectively improve the data interaction function and make their pages more colorful.

Effect:

Browse here

Code:

Paixu.xml

1 Sailflying A simple sort 2002-1-11 17:35:33 XML theme 2 flyingbird Marry you It is painful 2001-09-06 12:45:51 irrigation essence 3 Kozi regular expression in UBB forum application of 2001-11-23 21:02:16 Web programming essence 4 Tai Yi Lang year-end classic rudder party complete manual v0.1 2000-12-08 10:22:48 Forum Irrigation District 5 mmkk Asp error message summary 2001-10-13 16:39:05 javascript script

Paixu.xsl

Practical Battle package of XML Volume (1): dynamic sorting body,BlueIdea,team,blue_ID,blue_name,blue_text,blue_time,blue_class {font: 12px "Arial", "Arial", "Times New Roman";} table {font-size: 12px; border: 0px double; border-color: # 99CC99 # 99CC99 # CCCCCC # CCCCCC; cellpadding:3;cellspacing:3; bgcolor:#eeeeee; text-decoration: blink} span {font-size: 12px; color: red } function taxis (x) {stylesheet=document.XSLDocument; source=document.XMLDocument; sortField=document.XSLDocument.selectSingleNode ("/ / @ order-by"); sortField.value=x; Layer1 [XSS _ clean] = source.documentElement.transformNode (stylesheet);} practical kits of XML volumes (1): dynamic sorting

Serial number, name, subject, publication time classification

Explanation:

1) paixu.xml is a data file, so I believe everyone will have no problem.

2) paixu.xsl is a format file, there are several points to pay attention to.

(1) in the script:

SortField=document.XSLDocument.selectSingleNode ("/ / @ order-by")

The purpose is to find the first node with an attribute of order-by, so its corresponding node is

So the value of order-by on the first onLoad is blue_ID.

We achieve the purpose of sorting by redefining the value of order-by.

Layer1 [XSS _ clean] = source.documentElement.transformNode (stylesheet)

The purpose is to change the Layer1 after converting the XML data, so after the outgoing parameter 'blue_name'

Name

We change the value of order-by to 'blue_name', that is,' blue_name''as the sort.

The new sorted content is then displayed by redisplaying the innerHTML value of Layer1.

(2) in the text:

Order-by

This can not be less, or it will not be found, the effect, look at it!

Another point:

Encoding= "gb2312" is rarely added to the code shown in most XML textbooks.

Therefore, we will report an error when we use Chinese in XML because we did not write this statement.

The above is all the content of the article "sample Analysis of dynamic sorting in XML". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report