I am stuck with this php code.I need to parse the HTML DOM, using PHP, and extract the XPath of each Node, and the text value of each node;I know how to do it in JavaScript, here is my code: http://jsfiddle.net/2PxgE/7/That's what i want to do in PHP also;btw, te data is available in the console for js code;My problem is here : \[code\]$elements = $dom_xpath->query("*/div[@id='interestingbox']");\[/code\], because i dont know what kind of element comes next and what properties are available;\[code\]$html = '<html><head></head><body><div id="interestingbox"> <div id="interestingdetails" class="txtnormal"> <div>Content1</div> <div>Content2</div> </div></div><div id="interestingbox2"><a href="http://stackoverflow.com/questions/12795543/#">a link</a></div></body></html>';$dom_document = new DOMDocument();$dom_document->loadHTML($html);//use DOMXpath to navigate the html with the DOM$dom_xpath = new DOMXpath($dom_document);// if you want to get the div with id=interestingbox$elements = $dom_xpath->query("*/div[@id='interestingbox']");if (!is_null($elements)) { foreach ($elements as $element) { echo "\n[". $element->nodeName. "]"; $nodes = $element->childNodes; foreach ($nodes as $node) { echo $node->nodeValue. "\n"; } }}\[/code\]