How to convert HTML page to XHTML MP?

Is there any API / Tools?

If I have to implement it..
What are the possible considerations I need to take?
My plan is to convert HTML to DOM first.
Then parse DOM object to XHTML MP.
My problem is how to process the external css in the html.