Import Data From XML

Leave a Comment

 Hi All , 

In the following post I would like to show how to do the Import data from XML to Data verse using Power Apps and Power Automate.

I have defined my XML File like below and stored this file in SharePoint document library .

<?xml version="1.0"?>
<catalog>
<registration id="bk101">
<FirstName>PAUL KA</FirstName>
<LastName>WHITE</LastName>
<dob>2011-07-12</dob>
</registration>
<registration id="bk102">
<FirstName></FirstName>
<LastName></LastName>
<dob></dob>
</registration>
<registration id="bk103">
<FirstName></FirstName>
<LastName></LastName>
<dob></dob>
</registration>
</catalog>

















following is the Power Automate implementation at the high level.
























GetXML from the File Content.










GetXMLData from the Xpath xpath(xml(outputs('GetXML')), '//registration')








Now looping the XML content and adding the same to data verse table .

varXML - xpath(xml(item()), 'string(//author)')


















Checking for the dob null value before inserting to table.

empty(xpath(xml(item()),'string(//dob)'))

















DOB - xpath(xml(item()),'string(//dob)')

FirstName - xpath(xml(item()), 'string(//FirstName)')

LastName - xpath(xml(item()), 'string(//LastName)')


Calling Power Automate from Power Apps :

Now the above power automate will be called from Power Apps button , which will insert to records to data verse table .


UpdateContext({locSuccessMessage: ""});

Set(

    gblFlowStatus,

    Restore_GetData_XML.Run()

);

If(

    gblFlowStatus.completed = "true",

    UpdateContext({locSuccessMessage: "Import job completed successfully"});

    Refresh(Registrations)

);

ClearCollect(

    collErrorRegistration,

    Errors(Registrations)

);



Related Post

0 comments:

Post a Comment