Evaluate XPath 2.0 in PHP

☆樱花仙子☆ 提交于 2021-01-28 04:45:59

问题


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?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/28142859/evaluate-xpath-2-0-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!