关于xml排序问题!!很麻烦,要分送分!!大家帮下小妹

dreamsun 2003-11-21 02:13:02
有一个score.xml文件
<scorelist>
<score>
<s1>80</s1>
<s2>90</s2>
</score>
<score>
<s1>75</s1>
<s2>60</s2>
</score>
<score>
<s1>86</s1>
<s2>75</s2>
</score>
.
.
.
</scorelist>
用DOM读入score.xml,同时对s1,s2排序,然后再用DOM保存为该文件。
即是按s1,s2的大小排序
大的放在前面,小的放在后面。重新构造一份xml,然后保存

不能用XSL来排,请问大家如何实现?
...全文
31 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuzxit 2003-11-22
  • 打赏
  • 举报
回复
既然是又另存為xml文件﹐還有必要排序嗎?
ssm1226 2003-11-21
  • 打赏
  • 举报
回复
<%
dim xmldoc,node,nodes,s1,s2,nodeTemp
set xmldoc=server.createObject("MSXML2.DOMDocument")
xmldoc.async=false
if not xmldoc.load(server.mappath("test.xml")) then
response.write xmldoc.parseError.reason
response.end
end if
set nodes=xmldoc.documentELement.childNodes
for each node in nodes
s1=node.firstChild.text
s2=node.lastChild.text
if Clng(s1)<Clng(s2) then
set nodeTemp=node.firstChild.cloneNode(true)
node.removeChild node.firstChild
node.appendChild nodeTemp
end if
next
response.write xmldoc.xml
set xmldoc=nothing
%>
applexml 2003-11-21
  • 打赏
  • 举报
回复
其实你可以选择,在生成该Xml文档时,先进行你需要的排序,不OK 了吗?

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧