Is there a way to get a string representation of ancestors with QueryPath or DOM?
题
Something like:
find node: qp( $doc, 'UniqueSubNode' );
string representation: Root>Node>InnerNode>UniqueSubNode
解决方案
In QP parents() will get you all the ancestors, then all you need to do is html() each of them, I hope it helps.
Refer to this: http://api.querypath.org/docs/class_query_path.html#aae3c29dfc81839c3c054e7d608facd76
其他提示
Assuming your server allows you to use it you could use the DOMDocument object.
http://php.net/manual/en/class.domdocument.php
The DOMDocument object works in a fairly similar method to javascript's DOM manipulations. The text value is stored in the object's textContent member.
不隶属于 StackOverflow