Q:

Scrape HTML table and create XML in PHP

I already wrote a php script that logs into our school note system.  But I'm trying to parse the HTML page to xml.  But I'm running into some troubles.  First of all the html code of the tabel is kinda a mess and I have no clue what to do now.  
This is the CURL PHP page: http://koetse.eu/test/curl.php. 
This is the source code of the reply: http://pastebin.com/RDawmsnY
I'm trying to change that Messy HTML tabel into a xml file, looking somewhat like: 
<? xml version="1.0" ? > > 
<notes>
    <name>Jurre (4HC)</name>
            <class>kwt</class>
            <class>netl</class>
                    <note>6.6</note>
                    <note>6.3</note>
                    <note>4.9</note>
                    <se>5.8</se>
            <class>entl</class>
                    <note>7.5</note>
                    <note>7.3</note>
                    <note>7.7</note>
                    <note>10.0</note>
                    <note>6.6</note>
                    <note>9.6</note>
                    <note>6.7</note>
                    <note>6.7</note>
                    <se>8.6</se>
            <class>lv</class>
                    <note>7.8</note>
                    <note>4.8</note>
                    <se>6.3</se>
</notes>

ect... (I only did the first 3 rows as an example)
Sorry for using pastebin, But I got into a fight with the max length of a post. 
Regards Jurre

A:

Pretty surprised how no-one mentioned TIDY.  http://www.w3.org/People/Raggett/tidy/ .  Has officially saved my butt a few times.  I have managed to load your HTML in a DOM document without an issue after passing the garbage through it. 
There is, however, one significant mod I had to do after passing it through tidy - your school's systems output some tags which, whilst they would work perfectly in a XML doc, will just not work in HTML - wisssearch.  Search&replace using regular expressions and you've got a valid DOMDocument at the end! 
Things to do next:

Get rid of all those &xAA marks - regular expressions
Parse stuff! 

(tidy -f errors.txt -m your_file.txt )

