Put ProcessingInstruction Method in the beginning

The following code CREATE(XMLDom); XMLDom.loadXML(’’); objPI := XMLDom.createProcessingInstruction (‘xml’, ‘version=“1.0” encoding=“ISO-8859-1”’); XMLDom.insertBefore(objPI,XMLDom.childNodes.item(0)); objRoot := XMLDom.documentElement; objComment := XMLDom.createComment(‘Comment’); objRoot.appendChild(objComment); Gives this result i my XML file: - <?xml version="1.0" encoding="ISO-8859-1" ?> Instead I would like the following result <?xml version="1.0" encoding="ISO-8859-1" ?> - What am i doing wrong? The global variables are setup as follow: XMLDom -----> ‘Microsoft XML, v3.0’.DOMDocument30 objPI ------> ‘Microsoft XML, v3.0’.IXMLDOMProcessingInstruction objRoot ----> ‘Microsoft XML, v3.0’.IXMLDOMNode objComment → ‘Microsoft XML, v3.0’.IXMLDOMComment

Hi, i have changed your code a little: – snipp – CREATE(XMLDom); XMLDom.loadXML(’’); objPi := XMLDom.createProcessingInstruction (‘xml’, ‘version=“1.0” encoding=“ISO-8859-1”’); objRoot := XMLDom.documentElement; //XMLDom.insertBefore(objPi,XMLDom.childNodes.item(0)); XMLDom.insertBefore(objPi,objRoot); objRoot := XMLDom.documentElement; objComment := XMLDom.createComment(‘Comment’); objRoot.appendChild(objComment); – snap – so you get the expected result. Best regards Hartmuth