当前位置: 动力学知识库 > 问答 > 编程问答 >

PHP Parse XML using SimpleXML can't get string

问题描述:

I have tried a few examples I have found on answers made here, while I can get some parts of the XML using SimpleXML I am unable to get the part I need.

for instance, I can get the parts that are on top, they are not nested or anything, but the ones I need I have tried many ways and I can't.

for example i can get the bw info:

$xml=simplexml_load_file("http://163.172.209.150/stats");

$xml1->bw_in;

$xml1->bw_out;

but i am having trouble getting this part that says the number of users connected

["nclients"]=>

string(3) "146"

which is located all the wyay on the bottom, i have also tried using a foreach in other to get each stream users and just addd them up but i can't get that either.

is there some way I can get the number output by the nclients?

网友答案:

I figured out, I used XPath to get the result.

$xml->xpath("/rtmp/server/application/live/nclients");
分享给朋友:
您可能感兴趣的文章:
随机阅读: