web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Reading values from xml file

(0) ShareShare
ReportReport
Posted on by 932

Hi,

I have this xml File:

xml.png

I have table EUKSecurityTreeNode that have relation with another table EUKSecurityForm,EUKSecurityMenus et EUKSecurityMenuItems :

EUKSecurityTreeNode.euksecurityform=EUKSecurityForm.recid

EUKSecurityTreeNode.euksecuritymenu=EUKSecurityMenus.recid

EUKSecurityTreeNode.euksecuritymenuItems=EUKSecurityMenuItems.recid

I want when I go to the second node from "EUKSecurityTreeNode" I automatically go to the second node of the other tables "EUKSecurityForm",...to get the exact value.

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,866 Most Valuable Professional on at

    What's the context of your question? Are you trying to import this file through DIXF, are you trying to writing some custom code or what?

  • BASMA Profile Picture
    932 on at

    I export this file from base and I want to import it in another base.

    I do this with code.

    I want when I insert the values in euksecurityTreeynode,I find the corresponding values from the other tables means :

    when I insert the field "euksecurityForm" in "euksecuritytreenode " i should search this vlues in the table Euksecurityform

    case #EUKSecurityTreeNode :

    try
    {

    ttsBegin;
    EUKSecurityTreeNode=null;
    case #EUKSecurityForm:
    eukSecurityForm=eukSecurityForm::findName(nodelistrecords.item(6).innerText());

    break;

    case #EUKSecurityMenus:
    eukSecurityMenus=eukSecurityMenus::findName(nodelistrecords.item(7).innerText());

    break;

    EUKSecurityTreeNode.EUKSecurityForm=eukSecurityForm.RecId;

    EUKSecurityTreeNode.EUKSecurityMenus=eukSecurityMenus.RecId;
    EUKSecurityTreeNode.EUKSecurityMenuItems=eukSecurityMenuItems.RecId;
    EUKSecurityTreeNode.SecurityLevel = str2enum(securityLevel,nodelistrecords.item(3).innerText());
    EUKSecurityTreeNode.AOTNodePath = nodelistrecords.item(0).innerText();
    EUKSecurityTreeNode.EUKMatrixRoleVersion = str2int64(nodelistrecords.item(5).innerText());
    EUKSecurityTreeNode.EUKMatrixRole=eukMatrixRole.RecId;
    EUKSecurityTreeNode.EUKSecurityWorkflows=str2int64(nodelistrecords.item(10).innerText());
    EUKSecurityTreeNode.SecurableName=nodelistrecords.item(1).innerText();
    EUKSecurityTreeNode.SecurableType=str2enum(securableType,nodelistrecords.item(2).innerText());
    EUKSecurityTreeNode.Type=str2enum(type,nodelistrecords.item(9).innerText());
    EUKSecurityTreeNode.MatrixRole=nodelistrecords.item(11).innerText();
    EUKSecurityTreeNode.EUKSecurityForm=str2int64(nodelistrecords.item(6).innerText());
    EUKSecurityTreeNode.EUKSecurityMenus=str2int64(nodelistrecords.item(8).innerText());
    EUKSecurityTreeNode.EUKSecurityMenuItems=str2int64(nodelistrecords.item(7).innerText());
    EUKSecurityTreeNode.insert();
    ttsCommit;
    }
    catch
    {
    error("@EUK481");
    ttsAbort;
    }
    break;

    Can I do this??

  • BASMA Profile Picture
    932 on at

    Hi,

    have you any idea how can I get this structure in xml file :

    <EuksecurityTreeNode>

    <name></name>

    <type></type>

       <EukSecurityMenus>

             <name>  </name>

              <type> </type>

               .......

     </EulSecurityMenus>

    </EuksecurityTreeNode>

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Hi BASMA!

    You should use XmlDocument and XmlElement classes to create XML file.

    Here is an example:

    static void createXMLFile(Args _args)
    {
        XmlDocument doc;
        XmlElement  nodeXml;
        XmlElement  nodeTable;
        XmlElement  nodeAccount;
        XmlElement  nodeName;
        InventTable inventTable;
        Counter     test;
        #define.filename('<documents>\\test.xml')
    
        doc     = XmlDocument::newBlank();
        nodeXml = doc.createElement('xml');
    
        doc.appendChild(nodeXml);
    
        while select inventTable
        {
            nodeTable = doc.createElement(tablestr(inventTable));
            nodeTable.setAttribute(fieldstr(inventTable, RecId), int642str(inventTable.RecId));
            nodeXml.appendChild(nodeTable);
            nodeAccount = doc.createElement(fieldStr(inventTable, ItemId));
            nodeAccount.appendChild(doc.createTextNode(inventTable.ItemId));
            nodeTable.appendChild(nodeAccount);
            nodeName = doc.createElement(fieldStr(InventTable, NameAlias));
            nodeName.appendChild(doc.createTextNode(InventTable.NameAlias));
            nodeTable.appendChild(nodeName);
            
            test++;
            
            if (test > 10)
                break;
         }
    
        doc.save(#filename);
    }


  • BASMA Profile Picture
    932 on at

    Hi Rustem,

    thanks for your reply but I want to display multiple tables in the same file like this:

    <tableA>

    <name> </name>

    <type>   </type>

    <tableB> //has relation with tableA

       <name>   </name>

        <source> </source>

    </tableB>

    <tableC> //has relaion with tableA

    ....

    </tableC>

    </tableA>

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Just add it inside while select statement:

    static void createXMLFile(Args _args)
    {
        XmlDocument         doc;
        XmlElement          nodeXml;
        XmlElement          nodeTable;
        XmlElement          nodeAccount;
        XmlElement          nodeName;
        InventTable         inventTable;
        InventTableModule   inventTableModule;
        Counter             test;
        #define.filename('<documents>\\test.xml')
        
        doc     = XmlDocument::newBlank();
        nodeXml = doc.createElement('xml');
    
        doc.appendChild(nodeXml);
    
        while select inventTable
        {
            nodeTable = doc.createElement(tablestr(inventTable));
            nodeTable.setAttribute(fieldstr(inventTable, RecId), int642str(inventTable.RecId));
            nodeXml.appendChild(nodeTable);
            nodeAccount = doc.createElement(fieldStr(inventTable, ItemId));
            nodeAccount.appendChild(doc.createTextNode(inventTable.ItemId));
            nodeTable.appendChild(nodeAccount);
            nodeName = doc.createElement(fieldStr(InventTable, NameAlias));
            nodeName.appendChild(doc.createTextNode(InventTable.NameAlias));
            nodeTable.appendChild(nodeName);
            
            while select inventTableModule
                where inventTableModule.ItemId == inventTable.ItemId
            {
                nodeTable = doc.createElement(tablestr(InventTableModule));
                nodeTable.setAttribute(fieldstr(inventTableModule, RecId), int642str(inventTableModule.RecId));
                nodeXml.appendChild(nodeTable);
                nodeAccount = doc.createElement(fieldStr(inventTableModule, ModuleType));
                nodeAccount.appendChild(doc.createTextNode(enum2str(inventTableModule.ModuleType)));
                nodeTable.appendChild(nodeAccount);
                nodeName = doc.createElement(fieldStr(inventTableModule, UnitId));
                nodeName.appendChild(doc.createTextNode(inventTableModule.UnitId));
                nodeTable.appendChild(nodeName);
            }
    
            test++;
    
            if (test > 10)
                break;
         }
    
        doc.save(#filename);
    }


  • BASMA Profile Picture
    932 on at

    it's not the solution that I want :

    0081.xml.png

    I want that the node of euksecurityForm will be included in the node euksecurityTreeNode.

  • BASMA Profile Picture
    932 on at

    it's not the solution that I want :

    4604.xml.png

    I want that the node of euksecurityForm will be included in the node euksecurityTreeNode.

  • Rustem Galiamov Profile Picture
    8,072 on at

    So, euksecurityTreeNode and euksecurityForm need to be in the same level or not?

  • BASMA Profile Picture
    932 on at

    I want that the euksecurityForm will be included in the node of euksecurityTreeNode:

    <euksecurityTreeNode>

    <euksecurityForm>

                      i want here to get the information from the table euksecurityForm which has relation with  euksecurityTreeNode

    </euksecurityForm>

    </euksecurityTreeNode>

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans