It seems you are right. The returned object is not countable... it is an
object. Although it should theoretically be, because the example in the Zend
Documentation counts the results (the matches) the same way.

Why is it then, that my code doesn't work...? I am loading the xml file the
right way? In the meanwhile I have changed two things in my code... 1) I
have renamed the xml file to '/language/all_languages.xml', and, 2) I have
changed the xpath expression to "//tuv/seg[text()='English']"... and I have
confirmed that this expression matches something with the FireXPath
extension in Firefox.



drm-4 wrote:
> 
> oportell wrote:
>> $xmlfile = BASE_PATH . '/language/all_languages.tmx';
>> if (file_exists($xmlfile)) {
>>    $xml = file_get_contents($xmlfile);
>>    $dom = new Zend_Dom_Query();
>>    $dom->setDocumentXml($xml);
>>    $xpath = "//t...@xml:lang='en']";
>>    $results = $dom->queryXPath($xpath);
>>    $rows = count($results);
>> }
>>
>> But $rows always gets a value of 1. Why is that?
> I'm not familiar with Zend_Dom, but are you sure the returned object is 
> an array, or is Countable? You might just get an object, which does 
> contain multiple items, but count returns 1 for it. You shouldn't use 
> count() for debugging purposes just for this reason. Use gettype() / 
> get_class() in stead, and introspect the returned object based on it's 
> type, or use var_export / var_dump to debug.
> 
> This might not be the case though, just be aware of the possibility :-)
> 
> drm / Gerard
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Problems-using-Zend_Dom-tp26093704p26292269.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to