Problem in reading the XML TAG in X++ AX 2012

Hi All,

I am facing issue while reading a specific TAG in XML. Below is my XML in AX 2012. I am trying to read the XML which is in AIFQueueManager form in Dynamics AX (Table\AIFDocumentLog).

<?xml version="1.0" encoding="UTF-16"?>

-schemas.microsoft.com/.../services">](http://schemas.microsoft.com/dynamics/2008/01/services)

-schemas.microsoft.com/.../TrvPBSMaindata">](http://schemas.microsoft.com/dynamics/2008/01/documents/TrvPBSMaindata)

-

15.84

15.84

Subway

6677

PCARD

1122

Subway

USD

USD

“Craft, Tamaria L”

2015-11-05

TX

TX

I need to read different XML TAG Values like “AmountCurr”, CardNumber", "
Name". etc,

Is there any way that I can directly find the name of a TAG like “AmountCurr” and get the value from above XML.

I tried the below code but it was giving error in the red lines- XmlNode object not initialized.

str sourceXMLFile, sNumber, sName, sClass;
XmlDocument xmlDocument;
XmlNodeList nodeList;
XmlNode node;
XMLNodeListIterator xmlNodeListIterator;
Counter counter;
AifDocumentLog messageLog;
XmlElement element;
;

select firstOnly messageLog where messageLog.RecId == 5637146860 ;//5637147013;
sourceXMLFile = messageLog.DocumentXml;
xmlDocument = XmlDocument::newXml(sourceXMLFile);
nodeList = xmlDocument.selectNodes(’//TrvPBSMainData’);

xmlNodeListIterator = new xmlNodeListIterator(nodeList);
node = xmlNodeListIterator.value();
if(node.selectSingleNode(‘AmountCur’))
sNumber = node.selectSingleNode(‘AmountCur’).text();
while(xmlNodeListIterator.moreValues())
{
counter++;
// node = xmlNodeListIterator.value();

if(node.selectSingleNode(‘AmountCur’))
sNumber = node.selectSingleNode(‘AmountCur’).text();
if(node.selectSingleNode(‘CardNumber’))
sName = node.selectSingleNode(‘CardNumber’).text();
if(node.selectSingleNode(‘Name’))
sClass = node.selectSingleNode(‘Name’).text();

info(strFmt(“Record %1: AmountCur - %2, CardNumber - %3, Name - %4”,
counter,
sNumber,
sName,
sClass));
xmlNodeListIterator.nextValue();

Can anyone please help ?

It seems that you already got an answer in your duplicate thread on another forum, therefore you should have closed this one, so nobody wastes time trying to help you if you don’t need any help anymore.