hello dear Community, 8)
Again: first of all: felize Navidad - I wanna wish you a Merry Christmas!!
i’m trying to debug a little DOMDocument object in PHP. Ideally it’d be nice if I could get DOMDocument to output in a array-like format, to store the data in a database!
My example: head over to the url -
see the example: click the following target Bildungsserver Hessen - Siegfried-Pickert Schule
I investigated the Sourcecode: Note, I want to filter out the data that that is in the following class <div class=“floatbox”>
See the **sourcecode: **
<span class="grey"> <span style="font-size:x-small;">></span></span>
<a class="navLink" href="http://dms-schule.bildung.hessen.de/suchen/index.html" title="Suchformulare zum hessischen schulischen Bildungssystem">suche</a>
</div>
</div>
<!-- begin of text -->
<h3>Siegfried-Pickert Schule</h3>
<div class="floatbox">
See my approach: Here is the solution return the labels and values in a formatted array ready for input to mysql!
<?php
$dom = new DOMDocument();
@$dom->loadHTMLFile('http://dms-schule.bildung.hessen.de/suchen/suche_schul_db.html?show_school=8880');
$divElement = $dom->getElementById('floatbox');
$innerHTML= '';
$children = $divElement->childNodes;
foreach ($children as $child) {
$innerHTML = $child->ownerDocument->saveXML( $child );
$doc = new DOMDocument();
$doc->loadHTML($innerHTML);
//$divElementNew = $dom->getElementsByTagName('td');
$divElementNew = $dom->getElementsByTagname('td');
/*** the array to return ***/
$out = array();
foreach ($divElementNew as $item)
{
/*** add node value to the out array ***/
$out] = $item->nodeValue;
}
echo '<pre>';
print_r($out);
echo '</pre>';
}
well Duhh: this outputs lot of garbage. The code spits out a lot of html anyway.
What can i do to get a more cleaned up code!?
Question: What is wrong with the idea of using this attribute:
$dom->getElementById('floatbox');
any idea!? Can anybody have a look at the code and review it. I need to debug it a bit!
Any and all help will greatly appreciated.
season-greetings
db1