XPath查询结果顺序 [英] XPath query result order

查看:101
本文介绍了XPath查询结果顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于另一个问题,我创建了一些与XML相关的代码,这些代码适用于我的开发机器,但不适用于我的viper键盘在将其添加到我的答案之前对其进行了测试.

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.

我可以将问题减少到DOMXPath::query()返回的节点顺序在我的系统和键盘之间是不同的.

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>

当我查询所有textnodes //child::text()时,结果有所不同:

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

> 毒蛇键盘:

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

我的机器:

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

我对xpath并不了解,我确实理解为什么会发生这种情况以及使用PHP实现可能如何影响退货顺序.

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.

进一步的测试表明,LIBXML_VERSION在两个系统之间有所不同:

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)

推荐答案

我可以找到以下类似问题的错误报告:

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.

该问题应该已经在libxml2 2.6.27中修复.

This should have been fixed in libxml2 2.6.27.

这篇关于XPath查询结果顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆