PHP DOM XML 最好使用 xPath 读取
我有这个 xml
<App>
<Id id="129"/>
<Path id="category/self"/>
<Screenshots>
<Screenshot url="small_480x320_34eaefb6c934a0d82da637bec2276bdd_ebecfca09179d055ed4d3cf15a41bf7c-8f95512356608b888f288b374db7b37fabb3ce27.jpg"/>
<Screenshot url="small_480x320_438a9e1352bda4ef9724ae422473a556_615625ab835b09aa712e9c84c056cd7a-15bc8803724197129aea59577cac334736fadd3f.jpg"/>
<Screenshot url="small_480x320_ce4d635a786e427983c30f1abd8617a1_4d9b74b7f8ffa9ca19d64bee4a9592b9-36a9e665b0546b09e5496a5d02ba5e1bcd0bf563.jpg"/>
<Screenshot url="small_480x320_3e95d91de62aa2c52e4ff7f32a10a1d9_8a39c9eb9fa2bc2d5f5e789705713e12-a5ec1865bc88c6569af106d9131b45f1f82f8a1b.jpg"/>
<Screenshot url="small_480x320_3776b5fc7eceed4da9256105889578a3_4265bb97bda45a213357341ddaa81ce9-dae64333deb2cc09f69d0e74e79f4def199caaa2.jpg"/>
</Screenshots>
</App>
,我想解析它并
$Id = "129";
$Path = "category/self";
$Screenshots = array(... screenshots ... all 5 of them);
现在...我使用 XSLT 来做到这一点没有问题,但在阅读文档后我并不完全理解 DOM。到目前为止我所拥有的就是
这个 xpath 东西 http://codepad.org/BtvNEnjl 它只是读取之间的值标签,我不知道如何让它“foreach”它......
I have this xml
<App>
<Id id="129"/>
<Path id="category/self"/>
<Screenshots>
<Screenshot url="small_480x320_34eaefb6c934a0d82da637bec2276bdd_ebecfca09179d055ed4d3cf15a41bf7c-8f95512356608b888f288b374db7b37fabb3ce27.jpg"/>
<Screenshot url="small_480x320_438a9e1352bda4ef9724ae422473a556_615625ab835b09aa712e9c84c056cd7a-15bc8803724197129aea59577cac334736fadd3f.jpg"/>
<Screenshot url="small_480x320_ce4d635a786e427983c30f1abd8617a1_4d9b74b7f8ffa9ca19d64bee4a9592b9-36a9e665b0546b09e5496a5d02ba5e1bcd0bf563.jpg"/>
<Screenshot url="small_480x320_3e95d91de62aa2c52e4ff7f32a10a1d9_8a39c9eb9fa2bc2d5f5e789705713e12-a5ec1865bc88c6569af106d9131b45f1f82f8a1b.jpg"/>
<Screenshot url="small_480x320_3776b5fc7eceed4da9256105889578a3_4265bb97bda45a213357341ddaa81ce9-dae64333deb2cc09f69d0e74e79f4def199caaa2.jpg"/>
</Screenshots>
</App>
and i want to parse it and have
$Id = "129";
$Path = "category/self";
$Screenshots = array(... screenshots ... all 5 of them);
Now ... i have no problem doing this with XSLT for example, but i don't fully understand DOM after reading the documentation. All i have so far is
is this xpath thing http://codepad.org/BtvNEnjl that just read an value between tags and i don't know how to make it to "foreach" it ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)