What to do with this DOMXPath object?

Marcus

Well-known member
PHP:
    $amazon = new Zend_Service_Amazon(soso and so);
   
     $params = array(
         'SearchIndex' => 'All',
         'Keywords' => 'ipad'
     );
   
     $results = $amazon->itemSearch($params);
results into this object:

PHP:
object(Zend_Service_Amazon_ResultSet)#88 (4) {
  ["_results":protected] => object(DOMNodeList)#86 (1) {
    ["length"] => int(0)
  }
  ["_dom":protected] => object(DOMDocument)#90 (34) {
    ["doctype"] => NULL
    ["implementation"] => string(22) "(object value omitted)"
    ["documentElement"] => string(22) "(object value omitted)"
    ["actualEncoding"] => NULL
    ["encoding"] => NULL
    ["xmlEncoding"] => NULL
    ["standalone"] => bool(true)
    ["xmlStandalone"] => bool(true)
    ["version"] => string(3) "1.0"
    ["xmlVersion"] => string(3) "1.0"
    ["strictErrorChecking"] => bool(true)
    ["documentURI"] => string(38) "file:///xenforo/"
    ["config"] => NULL
    ["formatOutput"] => bool(false)
    ["validateOnParse"] => bool(false)
    ["resolveExternals"] => bool(false)
    ["preserveWhiteSpace"] => bool(true)
    ["recover"] => bool(false)
    ["substituteEntities"] => bool(false)
    ["nodeName"] => string(9) "#document"
    ["nodeValue"] => NULL
    ["nodeType"] => int(9)
    ["parentNode"] => NULL
    ["childNodes"] => string(22) "(object value omitted)"
    ["firstChild"] => string(22) "(object value omitted)"
    ["lastChild"] => string(22) "(object value omitted)"
    ["previousSibling"] => NULL
    ["attributes"] => NULL
    ["ownerDocument"] => NULL
    ["namespaceURI"] => NULL
    ["prefix"] => string(0) ""
    ["localName"] => NULL
    ["baseURI"] => string(38) "file:///xenforo/"
    ["textContent"] => string(19381) "d833eb0f-d49c-4b71-898a lot os stuff is here"
  }
  ["_xpath":protected] => object(DOMXPath)#87 (1) {
    ["document"] => string(22) "(object value omitted)"
  }
  ["_currentIndex":protected] => int(0)
}

How can I access the stuff? The results are really in the 'textContent', there are the links to the query (here: ipad), and if I change it to another keyword ('flower') I get results about flower-related stuff. Now I just need to access this huge big object. I tried to treat it like a DOMX object, then as a XML object, but I haven't found a php function that extracts information out of that huge object. Where could I start?
 
Last edited:
Thanks, do you have any idea how I can work with that document ?

PHP:
  $amazon = new Zend_Service_Amazon(soso and so);
 $params = array('SearchIndex' => 'All','Keywords' => 'ipad');
 $results = $amazon->itemSearch($params);
This does not work as $results is not identifierd to be a DOM class:
PHP:
$results->saveXML()

I would have to load $results into the Dom Class, but is there a way? This does not work, too :/
PHP:
 $doc =newDOMdocument();
 $doc->loadHTML($results);
 
saveXML().

I'd suggest reading through the documentation I linked above, it explains a lot.
 
I can not use saveXML() as the object is not classified as DOM.

PHP:
$amazon = new Zend_Service_Amazon(soso and so);$params = array('SearchIndex' => 'All','Keywords' => 'ipad');
$results = $amazon->itemSearch($params);
$results->saveXML();

Fatal error: Call to undefined method Zend_Service_Amazon_ResultSet::saveXML() in ...\ControllerPublic\Thread.php on line 42

Do you know how I can first do $doc =newDOMdocument(); and then put the content of $results into this document?
 
The DOM you receive is a DOMDocument. You may need to look up the documentation for Zend_Service_Amazon_ResultSet to find out how to access that dom.
 
Back
Top Bottom