I am currently working on a plugin page that automatically pulls information from an XML file using SOAP/WSDL.
I have no problem making the call and getting the data, however I have run into the following issue and I'm stuck:
I am looping through the data on the XML file using a while loop, but I must assign a set number of times to loop.. I cannot find a way to get the number of elements with success.
At this point, the data is put into an array for later use. Using this method, I am able to pull all the data from the XML file, however the number of elements contained in the file change regularly. I have attempted the following to get a count of the elements:PHP Code:
$dom = new DOMDocument();
$dom->loadXML($xml);
$i=0;
while ($i<100) {
$element[$i] = $dom->getElementsByTagName('element')->item($i)->nodeValue;
$i++;
}
However, the result is 1. Through experimentation, I found this:PHP Code:$CountVar = $dom->getElementsByTagName('element');
echo count($CountVar);
The result is again 1. I can keep going with the numbers after "element" and continue to get the same result of 1 until the XML document runs out of data.PHP Code:$CountVar = $dom->getElementsByTagName('element1');
echo count($CountVar);
I've been through the PHP documentation and I couldn't find anything in regard to this type of issue... can anyone please steer me in the right direction to finding a count?



Bookmarks