Map, MapEnumerator, pack/unpack using XML

static void testMapXml(Args _args)
{
    Map             map = new Map(Types::String, Types::Record);
    MapEnumerator   me;
    CustAccount     custAccount = '1001';
    CustTable       custTable   = CustTable::find(custAccount);
    container       cnt;
    str             xml;
    XmlDocument     xmlDocument;

    if (!map.exists(custAccount))
    {
        map.insert(custAccount, custTable);
    }

    if (map.elements())
    {
        me = map.getEnumerator();
        while (me.moveNext())
        {
            custAccount = me.currentKey();
            custTable   = me.currentValue();
        }
    }

    // pack/unpack Map to/from container
    cnt = map.pack();
    map = Map::create(cnt);

    // pack/unpack Map to/from XML
    xml         = map.xml();
    xmlDocument = XmlDocument::newXml(xml);
    map         = Map::createFromXML(xmlDocument.root() as XmlNode);
}

Support The Author

 If you found value in what I share, I've set up a Buy Me a Coffee page as a way to show your support.

Buy Me a Coffee

Post a Comment


All Comments


No comments. Be the first one to comment on this post.

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own "buy me a coffee" link.
Join us.

Blog Tags