Jump to content

Recommended Posts

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

Edited by MMDE

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();
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.