Welcome to WebmasterWorld Guest from 54.198.147.79

Forum Moderators: open

Message Too Old, No Replies

xpath saveHTML - how?

     
3:14 pm on Jul 19, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:May 11, 2008
posts:55
votes: 0


I'm stuck. Is there a way to effectively xpath to an html table and then save all of that tables html? The following is what I mean but of course it doesn't work.

$doc = new DOMDocument();
@$doc->loadHTMLFile("Test.txt");
$xpath = new DOMXPath($doc);
$x = $xpath->query("//div[@id='A-Div-Test']/table");
print $x->saveHTML();

Thanks,
Fred

11:54 pm on July 19, 2009 (gmt 0)

Senior Member from CA 

WebmasterWorld Senior Member httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 29, 2003
posts:4061
votes: 0


save - to where? another text file?

Assuming your HTML is also valid XML, if you get the right XPATH, you should be able to select it and convert it into a string.

perhaps DOMXPath::evaluate would do the trick?