How can I get child nodes

Ask questions here, report about problems.
Post Reply
martin
Posts: 2
Joined: Thu Nov 21, 2019 6:53 pm

How can I get child nodes

Post by martin » Fri Nov 22, 2019 10:42 am

Tell me how to get all the data of the child nodes in the Human Emulator Studio.
There is a site with such html code

Code: Select all

 
<div class="rc">
               <div class="r">
                  <a href="url" ping="/url?sa=t&amp;source=web&amp;rct=j&amp;url=/&amp;ved=2ahUKEwjGkfTS__vlAhUn_SoKHYr_BjoQFjAAegQIAxAB">
                     <h3 class="LC20lb"><span class="S3Uucc">...</span></h3>
                     <br>
                     <div class="TbwUpd"><cite class="iUh30"></cite></div>
                  </a>
.... here next  <div class="r"> 
.... etc

I need to loop around all div class="r" and get address of the first link

The position of the elements can change.

Please help.

User avatar
support
Site Admin
Posts: 65
Joined: Fri Feb 22, 2019 3:42 pm

Re: How can I get child nodes

Post by support » Fri Nov 22, 2019 11:22 am

Hi.

php example:

Code: Select all

// get all div with class=r
$lis = $div->get_all_by_attribute("class", "r", true);

foreach($lis->elements as $v) 
{
   // get child element with attribute ping contains /url?
   $link = $v->get_child_by_attribute ("ping", "/url?", false);

   // here you can get any child element attribute 
   echo $link->get_href()."<br>";
}

martin
Posts: 2
Joined: Thu Nov 21, 2019 6:53 pm

Re: How can I get child nodes

Post by martin » Fri Nov 22, 2019 12:22 pm

Thanks!

Post Reply