Trying to replace contents of a Div, with no luck
- by bluedaniel
Ive tried to use the Dom model with no bloody luck, getElementByID just doesnt work for me.
I loathe to resort to a regex but not sure what else to do.
The idea is to replace a <div id="content_div"> all sorts </div> with a new <div id="content_div"> NEW ALL SORTS HERE </div> and keep anything that was before or after it in the string.
The string is a partial HTML string and more specifically out of the wordpress Posts DB.
Any ideas?
UPDATE: I tagged this question PHP but probably should of mentioned Im looking for a PHP solution only.
Update: Code Example
$content = ($wpdb->get_var( "SELECT `post_content` FROM $wpdb->posts WHERE ID = {$article[post_id]}" ));
$doc = new DOMDocument();
$doc->validateOnParse = true;
$doc->loadHTMLFile($content);
$element = $doc->getElementById('div_to_edit');
So Ive tried a whole lot of code and this is what Ive got so far, probably not right but Ive been hacking at it for a little while now.