Create XML document

JesGJesG Member Posts: 4
edited 2006-10-24 in Dynamics AX
How do i create the first line in an xml document
<?xml version="1.0" encoding="UTF-8" standalone="Yes"?>

Comments

  • burdee64burdee64 Member Posts: 20
    Hi,

    I've scanned some sources written before, this is what I found:
    (It's from creating a purchase order in XML)

    For declaration:

    XMLProcessingInstruction XMLpi;
    XMLNode TopNode;
    XMLElement xmlElement;


    And the code:

    //Create header
    XMLpi = xmlDoc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"yes\" ");

    TopNode = xmlDoc.documentElement();
    xmlElement = xmlDoc.createElement('PurchaseOrder');
    TopNode = xmlDoc.appendChild(xmlElement);

    //Toevoegen header
    xmlDoc.insertBefore(XMLpi,TopNode.com());


    Hope this helps ya.

    Bert
    Bert van Dijk
    Rotor BV
  • MikerMiker Member Posts: 105
    Hi, JesG.
    May this code will help you
    static void SimplXMLCod(Args _args)
    {
    XMLDocument doc=XMLDocument::newXML('<?xml version="1.0" encoding="UTF-8"?><BranchCompany/>');
    // ('<?xml version="1.0" encoding="windows-1251"?><BranchCompany/>');
    doc.documentElement().setAttribute("attribute", "valueAttribute");
    doc.save("c:\\test.xml");
    info("ok");
    }

    MikeR (Axapta developer)
    going to Europe
Sign In or Register to comment.