yum install php-xml
test.server.com から WEBページを取得してきて<div id="myid">の要素を取得します。
$url='http://test.server.com';
// file_get_contents を使うより高速、ただしメモリは食う
require_once 'HTTP/Client.php';
$client =& new HTTP_Client();
$client->get($url);
$response = $client->currentResponse();
$dom = @DOMDocument::loadHTML( $response['body']);
$xml = simplexml_import_dom($dom);
$t = $xml->xpath('id("myid")');
if (! $t){ die('xpath error'); }
print_r( $t );
//* または /descendant::*
//div または /descendant::div
//html/head/title
//*[name()='li' or name()='div' ]
//div[@class='hoge'] /descendant::div[@class='hoge']
//div[@class='hoge fuga'] //div[contains(@class ,'hoge') and contains(@class ,'fuga')]
//li[contains(@class,'list')]
//div[@class='hoge']/text()
//div[@class='hoge']/.
id('hoge')
//*[@id='hoge']
/descendant::*[@id='hoge']
//div[text()='hogehoge']
//div[contains(text(), "fuga")]
//table//tr[th[text()='fuga']]
//*[@title='hoge' and @class!='fuga'] /descendant::*[@title='hoge' and @class!='fuga']
//form/descendant::input[3] /descendant::form/descendant::input[3]
//p[position() >=5]
***//input[@checked='checked']/.. //input[@checked='checked']/parent::node()
//link[@rel="alternate" and @type="application/rss+xml"]/@href
//*[@src='images/test.gif' ]
//img[contains(@src, '.gif')]
https://addons.mozilla.org/en-US/firefox/addon/xpath-checker/
http://itref.fc2web.com/xml/xpath.html
http://www.w3.org/TR/xpath/