Working with xml files in batch job

Hi everybody,

Excuse me for my english …

I have a class, extending RunBaseBatch, that read an xml file and create an other.

The code runs correctly but when it is executed in batch mode, the following error appears at the underlined line: “System.NullReferenceException: Object reference not set to an instance of an object.”

Xmldeclaration = xmlDoc.createXmlDeclaration(



XmlName = xmlDocument.childNodes().nextNode().nextSibling().name();

xmlElement = xmlDoc.createElement(XmlName);

XMLWrite = xmlDoc.appendChild(xmlElement);

XMLRead = rootNode.selectSingleNode(


Am i missing something ?

I am using Dynamics AX 2012.