使用变量获取simpleXML中的节点号 [英] using a variable to get the node number in simpleXML

查看:51
本文介绍了使用变量获取simpleXML中的节点号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当节点号是变量时,如何引用XML中的节点?


name [0]将返回名称为name的第一个节点的值。


我如何引用第n个节点的值?


或者是否无法对节点进行变量引用在PHP中的xml?


非常感谢

how does one refer to a node in XML when the node number is a variable?

name[0] will return the value of first node with the name "name"

how would I refer to the value of n-th node?

or is it not possible to make a variable reference to a node in xml in php?

thanks much

推荐答案

它可能最容易通过XPath做到这一点: // * [n + 1] 应该在文档中给你第n个节点。
it?s probably easiest to do that via XPath: //*[n+1] should give you the nth-node in the document.


谢谢D ..所以如果我的结构XML是

thanks D.. so if the structure of my XML is

展开 | 选择 | Wrap | 行号


你怎么看?


这篇关于使用变量获取simpleXML中的节点号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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