是否有一种方法可以选择1 XML节点内所有节点的和?
for $c in doc("http://www.dbis.informatik.uni-goettingen.de/Mondial/mondial.xml")
return count($c//country)
这是我目前拥有的,但这只返回所有顶级节点的计数。我想计数所有现有的节点。(递归?)
看一下下面的示例XML --
<div id="main">
<div id="1">
Some random text
</div>
<div id="2">
Some random text
</div>
<div id="3">
Some random text
</div>
<p> Some more random text&
是否有方法将路径作为变量传递给simplexml节点?这就是我试过的:
//set the path to the node in a variable
$comp = 'component->structuredBody->component';
echo count($xml->component->structuredBody->component); //=== 13
echo count($xml->$comp); //===0
echo count($xml->{$comp});//===0
有没有办法计算给定的xml文件中有多少个条目?
示例:
我的代码:
// The POST URL and parameters
$request = 'http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/driver/'.$u.'/cars?output=xml';
// Get the curl session object
$session = curl_init($request);
// Set the POST options.
curl_s