Home
> X++ stuffs > Reading Selected Node in XML – Dynamics AX2012
Reading Selected Node in XML – Dynamics AX2012
Case Study: Below a sample job is illustrated to read selected (multiple) nodes from a given XML.
private static void SR_ReadSelectedNode_XML(Filename fileName)
{
#define.node('INFORMATION//ROWS/ROW')
XmlDocument xmlDocument;
XmlNode xmlInformationNode;
XmlNodeList xmlInformationsNodeList;
XmlNodeList xmlChildNodeList;
int i;
int j;
fileName = @'C:\Projects\ReadNode.xml';
xmlDocument = xmlDocument::newFile(fileName);
xmlInformationsNodeList = xmlDocument.documentElement()
.selectNodes(#node);
setPrefix("@SYS98689");
for ( i = 0; i < xmlInformationsNodeList.length(); i++)
{
xmlChildNodeList = xmlInformationsNodeList.item(i)
.childNodes();
for (j = 0; j < xmlChildNodeList.length() ; j++)
{
xmlInformationNode = xmlChildNodeList.item(j);
if (xmlInformationNode.baseName() == 'DETAILS')
{
info(xmlInformationNode.innerXml());
break;
}
}
}
}
Categories: X++ stuffs
Goos aproach, however you should use a XmlNodeListIterator instead of a FOR loop.
Cheers.
Do you have anything which reads HTML file ?
good one. You can also use “Xpath” to create more standardized implementations and more flexible searchs http://www.w3schools.com/xpath/default.asp