Hi
I have a working import code in Ax 2009 that imports most of my XML files fine, but the selectSingleNode fails when there is a xmlns tag in the file (see below). I can parse the file and remove that tag before I load the XML document, but is there a better way to do this?
Here is a part of my code:
XMLDocument doc;
XMLNode rootNode,node;
XMLParseError xmlError;
XMLNodeList nodeList;
int i;
doc = new XMLDocument();
//doc.async(FALSE); // is this important?
doc.load(@"M:\ImportExport\Import\test.xml");
// Verify Document Structure
xmlError = doc.parseError();
if(xmlError && xmlError.errorCode() != 0)
{
throw error(strFmt("Error: %1",xmlError.reason()));
}
// Parsing document contents
rootNode = doc.documentElement();
singleNode = rootNode.selectSingleNode('PayrollProductionsChains'); // will only return a singlenode when I remove 'xmlns=...'
if(singleNode && xml2int(singleNode.selectSingleNode('PayrollProductionsChainID')))
{
...
}
First part of XML file that the code works with:
<?xml version="1.0" standalone="yes" ?>
- <PayrollDataSet>
- <PayrollProductionsChains>
<PayrollProductionsChainID>1</PayrollProductionsChainID>
<ChainID>1</ChainID>
First part of XML file that makes the import code fail:
<?xml version="1.0" standalone="yes" ?>
- <PayrollDataSet xmlns="http://tempuri.org/PayrollDataSet.xsd">
- <PayrollProductionsChains>
<PayrollProductionsChainID>1</PayrollProductionsChainID>
<ChainID>1</ChainID>