1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

What to do with this DOMXPath object?

Discussion in 'XenForo Development Discussions' started by Marcus, Aug 9, 2013.

  1. Marcus

    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: Aug 9, 2013
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

  3. Marcus

    Marcus Well-Known Member

    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);
     
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    saveXML().

    I'd suggest reading through the documentation I linked above, it explains a lot.
     
  5. Marcus

    Marcus Well-Known Member

    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();
    Do you know how I can first do $doc =newDOMdocument(); and then put the content of $results into this document?
     
  6. Jeremy

    Jeremy XenForo Moderator Staff Member

    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.
     

Share This Page