public function offsetSet($offset, $value)
{
if (NULL === $offset || $this->isNodeOffset($offset)) {
if (!$value instanceof \DOMNode) {
throw new \InvalidArgumentException('$value is not a valid \\DOMNode');
}
if (NULL === $offset) {
return $this->appendChild($value);
} else {
return $this->replaceChild($value, $this->childNodes->item((int) $offset));
}
} else {
return $this->setAttribute($offset, (string) $value);
}
}