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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Deserialize XML file

(0) ShareShare
ReportReport
Posted on by 390

Hey team,

I want to deserialize an XML file and extract the file name through x . Which function can I use to deserialize  the XML file to extract the file name? I saw an example but it uses a function which is dependent on Form Class which I don't want. Please can you help me with my issue.

Example I saw:

var classImported = FormRunConfigurationClass::deserialize(file, docuvalue.FileName);

I have the same question (0)
  • Sergei Minozhenko Profile Picture
    23,095 on at

    Hi skd,

    Do you want to deserialize XML file stored in document management to extract some values from the content?

  • skd Profile Picture
    390 on at

    Hey Sergei Minozhenko,

    The XML file is stored in the Docuref table.

    The code I referred to read the selected XML file from DocuRef and DocuValue Table. Now I want to deserialize the XML file to get the file name. How can I get it via x ?

    XmlDocument     xmlDoc = new XmlDocument();
            Filename filepath;
            Filename filename;
            Filename fileType;
            str fileNameString;
            DocuRef docuref;
            DocuValue   docuvalue;
    
            select firstonly docuref
                where docuref.recId == _docuRef.RecId
                join docuvalue
                    where docuvalue.recid == docuref.ValueRecId;
    
            DocuAction act = docuref.docuAction();
    
            System.IO.StreamReader sr = new System.IO.StreamReader(act.getStream(docuref));
    
            str file = sr.ReadToEnd();

  • Verified answer
    Sergei Minozhenko Profile Picture
    23,095 on at

    Hi skd,

    You can use XMLDocument class to deserialize XML and find elements you are interested in.

    XmlDocument xmlDoc = XmlDocument::newFromStream(DocumentManagement::getAttachmentStream(docuRef));

    www.axaptapedia.com/XMLDocument_class

  • skd Profile Picture
    390 on at

    Hey Sergei Minozhenko,

    By using this I'm not able to fetch my docs. It is throwing null exception. Please can you guide me as what have I done wrong. I simply want to read the XML file and fetch and the Owner(File) name.

    This is how I wrote my code:

               Filename filepath;
                Filename filename;
                Filename fileType;
                str fileNameString;
                DocuRef docuref;
                DocuValue   docuvalue;
                Description name;
                XmlElement          OwnerValue;
                XmlNode xmlNode;
    
            while select * from docuref where docuref.RefTableId == 17136  join docuvalue
                    where docuvalue.recid == docuref.ValueRecId
            {
                
            XmlDocument xmlDoc = XmlDocument::newFromStream(DocumentManagement::getAttachmentStream(docuRef));
                
                  xmlNode = xmlDoc.getNamedElement('OwnerValue');
                info(strFmt("Owner Name: %1", xmlNode.nodeValue()));
                }

    my XML File:

    Screenshot-_2800_152_2900_.png

  • Verified answer
    Sergei Minozhenko Profile Picture
    23,095 on at

    Hi skd,

    First, you need to find "FormRunConfigurationSerializer" element and in the found element, you need to find "OwnerValue" element

    xmlNode = xmlDoc.getNamedElement('FormRunConfigurationSerializer').getNamedElement('OwnerValue');

  • Sergei Minozhenko Profile Picture
    23,095 on at

    Hi skd,

    Also, use "text" method to get element value. NodeValue returns null for element node types.

    info(strFmt("Owner Name: %1", xmlNode.text()));

  • skd Profile Picture
    390 on at

    Hey Sergei Minozhenko,

    Thank you so much. It worked for me.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 616

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 460 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 331 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans