AX / D365FO – Remove all child nodes of a Parent node in XML #d365fo #ax #msdyn365fo

Imagine that your requirement is to write an XML file with some nodes inside, but in a specific case you must remove all the child nodes of a Parent node you have already written. Something like that: If you want to remove all child nodes of a parent node in an XML file you can … Continue reading AX / D365FO – Remove all child nodes of a Parent node in XML #d365fo #ax #msdyn365fo

AX / D365Fo – Add XSI:TYPE attribute in XML files – X++ #ax #msdyn365fo #d365fo

We want to create an XML file with : a namespace in the first element.an XSI prefix for XML elements attributes Desidered output <?xml version="1.0" encoding="UTF-8"?> <FirstElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SecondElement xsi:type="Attribute"/> </FirstElement> class temp { /// <summary> /// Runs the class with the specified arguments. /// </summary> /// <param name = "_args">The specified arguments.</param> public static … Continue reading AX / D365Fo – Add XSI:TYPE attribute in XML files – X++ #ax #msdyn365fo #d365fo

AX / D365Fo – Add Namespace and attributes (XSI:TYPE) with XSI prefix in XML files – X++ #ax #msdyn365fo #d365fo

We want to create an XML file with : a namespace in the first element.a prefix for every XML elementsa prefix for XML elements attributes Desidered output : <?xml version="1.0" encoding="UTF-8"?> <xsi:FirstElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <xsi:SecondElement xsi:type="Attribute"/> </xsi:FirstElement> So let's see how to do that in X++ class temp { /// <summary> /// Runs the class with … Continue reading AX / D365Fo – Add Namespace and attributes (XSI:TYPE) with XSI prefix in XML files – X++ #ax #msdyn365fo #d365fo

AX / D365FO – Create an xml file and download into the browser with File::SendFileToUser #d365fo #ax #msdyn365fo

To create an xml file you can use XmlNode class and if you want to save it into a folder you can use save method, but if you want to send to the user using the browser download functionality you have to use File::SendFileToUser method. This method accepts only a MemoryStream so you must convert … Continue reading AX / D365FO – Create an xml file and download into the browser with File::SendFileToUser #d365fo #ax #msdyn365fo

AX / D365FO – Set custom XML Namespaces Attributes (xmlns, xsi, etc..)

Use setAttribute method() to add custom Namespace to an XML node like shown below //Create XML Document XMLDocument xmlDoc; XMLNode root; XMLElement element; xmlDoc = XMLDocument::newBlank(); element = xmlDoc.createElement('Invoice'); element.setAttribute('xmlns',"urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"); element.setAttribute('xmlns:cac',"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateCoomponents-2"); element.setAttribute('xmlns:cbc',"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"); element.setAttribute('xmlns:ccts',"urn:un:unece:uncefact:documentation:2"); element.setAttribute('xmlns:ext',"urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"); element.setAttribute('xmlns:qdt',"urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2"); element.setAttribute('xmlns:udt',"urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2"); element.setAttribute('xmlns:xsd',"http://www.w3.org/2001/XMLSchema"); element.setAttribute('xmlns:xsi',"http://www.w3.org/2001/XMLSchema-instance"); element.setAttribute('xsi:schemaLocation',"urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"); root = xmlDoc.appendChild(element);

AX – D365FO – Create an XML file in X++

Reference article : https://shyamkannadasan.blogspot.com/2016/06/ax-creates-xml-file-in-x-containing.html This example create an XML file in X++ containing employee details static void XMLWriteEmplAddr(Args _args) { FileIoPermission permission; XMLDocument xmlDoc = XMLDocument::newBlank(); XMLNode rootNode; XMLNode NodeEmpl, NodeName, NodeAddr; XMLElement xmlElement; XMLText xmlText; HCMWorker HCMWorker; permission= new FileIoPermission('C:\\Altitudo\\Empl_Details_List.xml','w'); permission.assert(); xmlDoc = XMLDocument::newBlank(); // Create first line containing version info rootNode = xmlDoc.documentElement(); … Continue reading AX – D365FO – Create an XML file in X++