在 PHP 中评估 XPath 2.0 [英] Evaluate XPath 2.0 in PHP

查看:21
本文介绍了在 PHP 中评估 XPath 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在处理一个用 PHP 编写的项目,并想评估 XML 文件上的 XPath 表达式.由于文件非常复杂,我的 XPath 包含表达式,例如 for...in...return-loops 或 XPath 2 引入的其他功能.不幸的是 PHP 的 DOMXPath 类仅支持 XPath 1.0,我没有找到任何适用于 PHP 的 XPath 2.0 评估器.有没有人遇到过同样的问题并找到了解决方案?

I am currently working on a project written in PHP and want to evaluate XPath expression on XML files. Since the files are a quite complex, my XPath contains expressions like for...in...return-loops or other features introduced with XPath 2. Unfortunately PHP's DOMXPath class supports only XPath 1.0, and I didn't find any XPath 2.0 evaluator for PHP. Has anybody faced the same problem and found a solution?

推荐答案

Saxon/C(目前处于测试阶段)可以从 PHP 调用.它是开源的,受 Mozilla Public License 2.0 保护.支持 Linux、Windows 和 Mac OS X.

Saxon/C (currently in beta) can be called from PHP. It's open source, covered under the Mozilla Public License 2.0. Linux, Windows and Mac OS X are supported.

或者,代替对 XPath 2.0 的支持,您可以重新编写 XPath 以正确使用 XPath 1.0 并在 PHP 本身中覆盖 XPath 之外的迭代等.

Alternatively, in lieu of support for XPath 2.0 you could just re-write your XPaths to use XPath 1.0 proper and cover iteration etc outside of XPath in PHP itself.

这篇关于在 PHP 中评估 XPath 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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