wittiws / quipxml
v0.2.3
2018-08-09 15:35 UTC
Requires
- php: >=5.4
This package is auto-updated.
Last update: 2020-02-27 17:08:26 UTC
README
QuipXml 是模仿jQuery的XML操作PHP对象链式调用。
尽管这个项目正在开发中,带有单元测试,但仍然是alpha版本。方法名可能会更改。
基本用法
// The 'load' factory method aligns with SimpleXml constructor arguments. $quip = Quip::load($xml_path, 0, TRUE); $quip = Quip::load($xml_string); // jQuery method names are used where appropriate. $html = $quip->html(); // jQuery method names are adjusted when there is a keyword conflict. $quip->xparent(); // While jQuery syntax is wonderful, you also get PHP advantages: // 1. xpath // 2. access children like properties // 3. use foreach loops $ul = $quip->xpath("//ul")->eq(0); $ul->li->after('<li>New bullet.</li>'); foreach ($quip->xpath("//li")->eq(1) as $li) { } // For advanced operations, just like in jQuery, you can access the DOMNode for a given XML node. $el = $ul->dom();
HHVM对SimpleXML的限制
自2014年3月24日起生效(在travis-ci上确认),您不能在SimpleXml元素上使用魔法self-reference。此代码将不会工作
$sxml = simplexml_load_file('example.xml'); $sxml->original[0] = $expected;
更新:此问题已在HHVM 3中修正(在2014年5月30日的travis-ci上确认)。