Welcome! Here you can paste sources and general debugging text, You can even set yourself a password if you want to keep it just for yourself.

Posted by dom on February Mon 23rd 10:09 AM - Never Expires - Views: 439

  1. $xpath = new DomXPath($dom);
  2. $nodesImg = $xpath->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' $classnameImg ')]");
  3. ^estou pegando o elemento com a classe x através desse comando^
  4.  
  5. me retorna isso no var_dump($nodesImg);
  6.  
  7. object(DOMNodeList)#64 (1) {
  8.  ["length"]=>
  9.   int(30)
  10. }
  11.  
  12. agora tentei trabalhar também com ele em array.
  13.  
  14. function dnl2array($domnodelist) {
  15.         $return = array();
  16.         for ($i = 0; $i < $domnodelist->length; ++$i) {
  17.             $return[] = $domnodelist->item($i);
  18.         }
  19.         return $return;
  20.     }
  21.  
  22. $arrayNodesImg = dnl2array($nodesImg);
  23.  
  24.  [28]=>
  25.   object(DOMElement)#62 (18) {
  26.    ["tagName"]=>
  27.     string(3) "div"
  28.     ["schemaTypeInfo"]=>
  29.     NULL
  30.     ["nodeName"]=>
  31.     string(3) "div"
  32.     ["nodeValue"]=>
  33.     string(11) "
  34.                                        
  35.                                 "
  36.     ["nodeType"]=>
  37.     int(1)
  38.     ["parentNode"]=>
  39.     string(22) "(object value omitted)"
  40.     ["childNodes"]=>
  41.     string(22) "(object value omitted)"
  42.     ["firstChild"]=>
  43.     string(22) "(object value omitted)"
  44.     ["lastChild"]=>
  45.     string(22) "(object value omitted)"
  46.     ["previousSibling"]=>
  47.     string(22) "(object value omitted)"
  48.     ["nextSibling"]=>
  49.     string(22) "(object value omitted)"
  50.     ["attributes"]=>
  51.     string(22) "(object value omitted)"
  52.     ["ownerDocument"]=>
  53.     string(22) "(object value omitted)"
  54.     ["namespaceURI"]=>
  55.     NULL
  56.     ["prefix"]=>
  57.     string(0) ""
  58.     ["localName"]=>
  59.     string(3) "div"
  60.     ["baseURI"]=>
  61.     NULL
  62.     ["textContent"]=>
  63.     string(11) "
  64.                                        
  65.                                 "
  66.   }
  67.  
  68. ^me retorna isso.
  69.  
  70. Nos dois casos eu tenho que percorrer o child elementes dessa div. e encontrar o href e pegar sua url.
  71.  
  72. Só que fiz varias tentativas e nada.
  73.  
  74. Alguem consegue me auxiliar?
  75.  
  76. Valeu!!!!
Language:
To highlight particular lines, prefix each line with @@




© 2017  YSblue.com.br (Implemented and Adapted) - Powered by PASTE 1.0