dpmwy80068 2011-11-19 17:10
浏览 139
已采纳

XPath查询结果顺序

For another question I have created some XML related code that works on my development machine but not on viper codepad where I tested it before adding it to my answer.

I could reduce my problem to the point that the order of nodes returned by DOMXPath::query() differs between my system and the codepad.

XML: <test>This is some <span>text</span>, fine.</test>

When I query all textnodes //child::text() the result differs:

Viper Codepad:

#0: This is some 
#1: , fine.
#2: text

My Machine:

#0: This is some 
#1: text
#2: , fine.

I'm not that experienced with xpath that I do understand why this happens and how it's probably possible to influence the return order with the PHP implementation.

Edit:

Further testing has revealed that LIBXML_VERSION differs between the two systems:

Viper Codepad: 20626 (2.6.26; 6 Jun 2006)
My Machine...: 20707 (2.7.7; 15 Mar 2010)
  • 写回答

5条回答 默认 最新

  • douyi8408 2011-11-19 19:12
    关注

    I could find the following bug-report which looks like the issue: Bug 363252 - proximity position in libxml2's xmlXPathEvalExpression() reported 18 Oct 2006 and confirmed dating back since May 2006 which is before the 2.6.26 version in question.

    This should have been fixed in libxml2 2.6.27.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧