将网站转换为xml?

I am using this code to get content of a web site:

$data = file_get_contents('http://domain.com/');

And for now, I want to convert $data to an XML object to parse it easily. For example:

<?xml version='1.0' encoding='ISO-8859-1'?>
<html>
    <body>
         <div id='main'>
         </div>
    </body>
</html>

Thank in advance

There are several classes and API's built into PHP and ready to use.

Take a look here: http://www.php.net/manual/en/refs.xml.php

Since your using the source of a website, you'd be best using DOMDocument and loading it as HTML (since that's what it is).

$data = file_get_contents('http://example.com/');
$dom = new DOMDocument();
$dom->loadHTML( $data );

Why do you want to convert it to xml? You can parse it as html easily as well..

For example just use http://php.net/manual/pl/class.domdocument.php