<? some text ?>
is a processing instruction. The node is of type NODE_PROCESSING_INSTRUCTION
.
Retrieve the node as the first child of the document, using get_childNodes
and delete it with removeChild
.
Then, use createProcessingInstruction
for the new encoding and use insertBefore
(with the new first child) to add it to the document.