
Originally Posted by
skeeterbug
thanks for the heads up.
i updated the code to read:
PHP Code:
for($i=0; $i < $num_elements; $i+=2){
$j = $i+1;
$query = $GOBALS['xpath']->query($GLOBALS['new_text'][$i]);
$node = $query->item(0);
$node->nodeValue = $GLOBALS['new_text'][$j];
}
it still failes to work - still get the WSOD.
i've never been able to get
error_reporting(E_ALL);
to work on my winxp cgi install. i do have an IDE that reports errors, though. in the case, the IDE doesn't print out any fatal errors.
is there a standard syntax for getting objects into for loops (in my case, the dom and the xpath objects? i probably mispoke before when i said variables. i probably should've said objects.
tia...
i mispelled $GLOBALS again. i've done it right and it doesn't work.
PHP Code:
function update_xml_file($xml_file, $doc, $xpath, $new_text){
// $new_text is array with query path and new text value pairs.
$num_elements = count($new_text);
for($i=0; $i < $num_elements; $i+=2){
$j = $i+1;
$query = $GLOBALS['xpath']->query($GLOBALS['new_text'][$i]);
$node = $query->item(0);
$node->nodeValue = $GLOBALS['new_text'][$j];
}
file_put_contents($xml_file, $doc->saveXML());
}
ps - just saw that clam was on it before i realized it. good eyes!
it still doesn't work, though.
i even tried a while loop...
PHP Code:
function update_xml_file($xml_file, $doc, $xpath, $new_text){
// $new_text is array with query path and new text value pairs.
$num_elements = count($new_text);
$i=0;
while ( $i < $num_elements ) {
$j = $i+1;
$query = $xpath->query($new_text[$i]);
$node->nodeValue = $new_text[$j];
$i+=2;
}
file_put_contents($xml_file, $doc->saveXML());
}
i no longer get the WSOD, though. i think that had to do with $GOBALS. 
it displays the screen, but it doesn't update my xml file.
i think i'm losing $doc (DOMDocument object) and $xpath (DOMXpath object).
Bookmarks