I have tried to find a way to "bookmark" an element on a page so i will later on be able to check on it. everything I've tried so far lead me to some problem so I've came to the conclusion that finding the absolute path might be the only way.
I am new to xpath or DOMdocument in general so i might have the naming wrong however by absolute path i mean something like:
"/html/body/div[1]/div[1]/div[2]/span[2]"
lets say i use:
$element_with_something = $xpath->query('(//*[text()= "something"])');
This gave me an element. now my question is there an easy way of finding it's absolute path. if not. then i will probably have to recursion my way up the tree.
if so how can i check if an element has a parent?
I know i can use hasChildNodes()
to find child but is there a way to find out if there is a parent ? or any other way to break the recursion ones it hit the top of the tree ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…