cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Spawn10
Level: Powered On

How do I generate an xml file from data captured?

I have an PowerApps app that accepts data from users, and I am patching the data into a SharePoint list...

Patch(SharePointListName, Defaults(SharePointListName),
    { user_info: Concatenate(
        first_name.Text," , ",
        middle_initial.Text," , ",
        last_name.Text," , ",
        nickname.Text," , "
        ),
		section_req: Concatenate(
        Radio_Status.Selected.Value
        ),
		requestors_info: Concatenate(
        requestors_name.Text," , ",
        phone_number.Text," , ",
        additional_comments.Text," , ",
        Dmanager.Text," , "
        )
    }
)

I want to be able to generate an xml, and I don't know how to get this going. My requirement is to get an xml file like this...

<my:myFields xml:lang="en-US" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
	<my:section_1>
		<my:type>1</my:option_type>
	</my:section_request_type>
	<my:section_user_info>
		<my:text_first_name>Ken</my:text_first_name>
		<my:text_middle_initial></my:text_middle_initial>
		<my:text_last_name>Ryu</my:text_last_name>
		<my:text_nickname>ShoRyuKen</my:text_nickname>
		<my:text_job_title></my:text_job_title>
	</my:section_user_info>
	<my:section_req>
		<my:option_employee_status>Full</my:option_employee_status>
		<my:section_contract_term>
	</my:section_req>
	<my:section_requestors_info>
		<my:text_requestors_name>Shang Tsung</my:text_requestors_name>
		<my:text_requestors_phone_number>800.555.5555</my:text_requestors_phone_number>
		<my:rtext_additional_comments></my:rtext_additional_comments>
		<my:text_manager>Shao Kahn</my:text_manager>
	</my:section_requestors_info>
</my:myFields>

Is there a way to get this out of the SharePoint list entry? Or is there a way of getting this done directly in PowerApps?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: How do I generate an xml file from data captured?

@Spawn10 

There is no direct way in PowerApps to get that converted into XML.

Your best choice in PowerApps would be to Concatenate the XML and build it based on the values in your record. Similar to what you are doing in your patch.

Concatenate("<my:section_user_info>
		<my:text_first_name>", first_name.Text, "</my:text_first_name>
		<my:text_middle_initial>", middle_initial.Text, "</my:text_middle_initial>
		<my:text_last_name>", last_name.Text, "Ryu</my:text_last_name>
… and so forth

You can put that formula on in a TextInput control or a label or wherever you want so you can reference it and see it, or just put it in a variable as well.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

2 REPLIES 2
Super User
Super User

Re: How do I generate an xml file from data captured?

@Spawn10 

There is no direct way in PowerApps to get that converted into XML.

Your best choice in PowerApps would be to Concatenate the XML and build it based on the values in your record. Similar to what you are doing in your patch.

Concatenate("<my:section_user_info>
		<my:text_first_name>", first_name.Text, "</my:text_first_name>
		<my:text_middle_initial>", middle_initial.Text, "</my:text_middle_initial>
		<my:text_last_name>", last_name.Text, "Ryu</my:text_last_name>
… and so forth

You can put that formula on in a TextInput control or a label or wherever you want so you can reference it and see it, or just put it in a variable as well.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Community Support Team
Community Support Team

Re: How do I generate an xml file from data captured?

Hi @Spawn10 ,

Could you please share a bit more about your scenario?

Do you want to generate a xml data/file based on a data entry within your app?

 

If you want to generate a xml data/file based on a data entry within your app, I afraid that there is no way to achieve your needs in PowerApps currently.

There is no way or functions supported within PowerApps to convert a data entry into a xml data/file. If you would like this feature to be added in PowerApps, please consider submit an idea to PowerApps Ideas Forum:
https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

 

As an alternative solution, you could consider generate a xml string within your app with related data from users, then pass the generated xml string value into a flow (Microsoft Flow), within the flow, you could use the genrated xml string value to create a xml file.

I have made a test on my side, please take a try with the following workaround:

Microsoft Flow's configuration as below:4.JPG

Within the "Create file" action, you need to specify the parameters you want to pass from your app to this flow using the "Ask in PowerApps" dynamic content.

 

PowerApps app's configuration as below:5.JPG

Set the OnSelect property of the "Fire Flow" button to following:

'20190613_case1'.Run("PowerAppsTest.xml", "<?xml version='1.0' ?><root><name>PowerApps</name><executor>Kris</executor></root>")

On your side, you need to create a connection to above flow within your app, then add a "Button" within your app, set the OnSelect property of the "Button" to following:

'YourFlowName'.Run(
                    "PowerAppsTest.xml", /* <-- Type your xml file name e.g. xxx.xml  */
                    "<my:myFields xml:lang='en-US' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' >
	                <my:section_request_type>
		            <my:type>1</my:type>
	                </my:section_request_type>
	                <my:section_user_info>
		             <my:text_first_name>" & first_name.Text & " </my:text_first_name>
		             <my:text_middle_initial>" & middle_initial.Text & "</my:text_middle_initial>
		             <my:text_last_name>" & last_name.Text & "</my:text_last_name>
		             <my:text_nickname>" & nickname.Text & "</my:text_nickname>
		             <my:text_job_title></my:text_job_title>
	                </my:section_user_info>
	                <my:section_req>
		             <my_employee_status>" & Radio_Status.Selected.Value & "</my_employee_status>
		             <my:section_contract_term>
	                </my:section_req>
	                <my:section_requestors_info>
		              <my:text_requestors_name>" & requestors_name.Text & "</my:text_requestors_name>
		              <my:text_requestors_phone_number>" & phone_number.Text & "</my:text_requestors_phone_number>
		              <my:rtext_additional_comments>" & additional_comments.Text & "</my:rtext_additional_comments>
		              <my:text_manager>" & Dmanager.Text & "</my:text_manager>
	                </my:section_requestors_info>
                   </my:myFields>"
)

Note: Please replace the double quotes ("") within your generated xml string value with single quote ('').

 

More details about firing a flow from an app, please check the following article or video:

Start a flow from a canvas app

https://www.youtube.com/watch?v=1wl9AtxWdkg

 

When you press the "Fire Flow" button within your app, it would fire a flow, and pass the specified parameters to your flow. Within your flow, it would create a xml file based on passed xml file name and xml file string content. The flow would be executed as below:6.JPG

7.JPG

 

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,649)