how i can getting xpath address of a string in html code?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mikhak
Forum Newbie
Posts: 1
Joined: Wed Sep 23, 2015 1:47 am

how i can getting xpath address of a string in html code?

Post by mikhak »

Hi

i want know how i can getting a xpath address
of a string in html code. for example i want finding xpath of YES in this html code :

Code: Select all

<div><div>
<div><div>
   <div>
      <p>NO</p>
        <div>
           <p>a text</p>
        </div>
   </div>
</div>
<div>
   <div>
      <p>YES</p>
        <div>
           <p>b text</p>
        </div>
   </div>
</div></div>
</div></div>
i used the http://php.net/manual/en/domnode.getnodepath.php but thats only work with tag name and not working with a word or text searching in a string.

i want getting like this result finally :

Code: Select all

/html/body/div/div/div/div[2]/div/p
how i can doing like that ?

and is it possible doint that with php simple_html_dom parser ?

Thanks.
Post Reply