MMDE Posted November 4, 2012 Share Posted November 4, 2012 Heya I use DOMDocument and loadHTML to run through some data of a HTML page. My problem is that when I for example do this: $trs = $site->getElementsByTagName('tr'); while($tr AS $tr){ $td = $tr->childNodes->item(0); $newString = $td->nodeValue; } The string in the <td> can contain for example a br tag, and if that is the case, I would like to include it at it's correct position. I know how to check if the td tag has a br tag, but I don't know how to apply it at it's correct position in the string $newString. Anyone got any good ideas? BTW, the post new editor is kinda bad for this type of a forum. I got no idea how to add tabbed spaces, and the title of the thread all of a sudden had capital letters at the beginning of each word and it has decapitilized the rest. I wanted it to be: DOMDocument, loadHTML and line break problem - MMDE Link to comment https://forums.phpfreaks.com/topic/270281-domdocument-loadhtml-and-line-break-problem/ Share on other sites More sharing options...
MMDE Posted November 4, 2012 Author Share Posted November 4, 2012 I found a solution myself. function getNodeInnerHTML($domn){ $domd = new DOMDocument(); if($domn->hasChildNodes()){ foreach($domn->childNodes as $domnc){ $domd->appendChild($domd->importNode($domnc, true)); } } return $domd->saveHTML(); } Link to comment https://forums.phpfreaks.com/topic/270281-domdocument-loadhtml-and-line-break-problem/#findComment-1390167 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.