You need to modify your code to look like the following:
$team1sabbr = $dom->getElementsByTagName('team1sabbr');
$textNode = $dom->createTextNode('value-1');
foreach ($team1sabbr as $team) {
$team->parentNode->replaceChild($textNode, $team);
}
- Iterate through each found element
- Locate the parent of that element
- Use
replaceChild
on the parent node.
Edit::
Through comments it seems the question was unclear.
The following is what was required.
$team1sabbr = $dom->getElementsByTagName('team1sabbr');
foreach ($team1sabbr as $team) {
$team->nodeValue = 'value-1';
}