cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Patron
Post Patron

Reading XML from Infopath file

I'm trying to convert some InfoPath forms to just SharePoint list items and I think I'm most of the way there. 

 

I'm trying a Compose action to do an xpath function and return the data inside. 

 

My data looks like:

 

<?xml version="1.0" encoding="utf-8"?>

<my_myFields xmlns_xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns_pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls" xmlns_xhtml="http://www.w3.org/1999/xhtml" xmlns_ma="http://schemas.microsoft.com/office/2009/metadata/properties/metaAttributes" xmlns_d="http://schemas.microsoft.com/office/infopath/2009/WSSList/dataFields" xmlns_q="http://schemas.microsoft.com/office/infopath/2009/WSSList/queryFields" xmlns_dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns_dms="http://schemas.microsoft.com/office/2009/documentManagement/types" xmlns_tns="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns_soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns_ns1="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService" xmlns_s1="http://microsoft.com/wsdl/types/" xmlns_http="http://schemas.xmlsoap.org/wsdl/http/" xmlns_tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns_ns2="http://schemas.xmlsoap.org/wsdl/soap/" xmlns_soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns_mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns_soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns_wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns_my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2016-08-03T15:39:25" xmlns_xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-US">
	<my_Requestor>
		<pc_Person>
			<pc_DisplayName>Test Person</pc_DisplayName>
			<pc_AccountId>i:0#.f|membership|test.person@testfacility.com</pc_AccountId>
			<pc_AccountType></pc_AccountType>
		</pc_Person>
	</my_Requestor>
	<my_BusinessStakeholders></my_BusinessStakeholders>
	<my_ProjectTitle>Test Facility Closure</my_ProjectTitle>
	<my_FacilitySelectionGroup>
		<my_FacilitySelection></my_FacilitySelection><my_FacilitySelection>Test Facility</my_FacilitySelection>
	</my_FacilitySelectionGroup>
	<my_City></my_City>
	<my_State>[Select State]</my_State>
	<my_StartDate>2019-07-09</my_StartDate>
	<my_EndDate>2019-09-30</my_EndDate>
	<my_Resources>
		<pc_Person>
			<pc_DisplayName></pc_DisplayName>
			<pc_AccountId></pc_AccountId>
			<pc_AccountType></pc_AccountType>
		</pc_Person>
	</my_Resources>
	<my_CostPreliminary></my_CostPreliminary>
	<my_CostProject></my_CostProject>
	<my_HoursPreliminary></my_HoursPreliminary>
	<my_HoursProject></my_HoursProject>
	<my_CapitalProject></my_CapitalProject>
	<my_ProjectScope><html xmlns="http://www.w3.org/1999/xhtml" xml:space="preserve"><p>​Facility Closure</p>
</html></my_ProjectScope>
	<my_PMONotes></my_PMONotes>
	<my_ApproverSection>
		<my_CreateSite>No</my_CreateSite>
		<my_Category>Closure</my_Category>
		<my_AssignedPM>
			
		<pc_Person xmlns_pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls"><pc_DisplayName>Test Person</pc_DisplayName><pc_AccountId>i:0#.f|membership|test.person@testfacility.com</pc_AccountId><pc_AccountType>User</pc_AccountType></pc_Person></my_AssignedPM>
		<my_CreateProjectSiteSection>
			<my_URL></my_URL>
			<my_CategoryURL></my_CategoryURL>
		</my_CreateProjectSiteSection>
	</my_ApproverSection>
	<my_RejectionPage>
		<my_RejectType></my_RejectType>
		<my_RejectionMessage></my_RejectionMessage>
	</my_RejectionPage>
	<my_Variables>
		<my_ApproveStatus>Approved</my_ApproveStatus>
		<my_ProjectURL>https://test.sharepoint.com/teams/ITProjects//</my_ProjectURL>
		<my_ProjectCategoryURL>https://test.sharepoint.com/teams/ITprojects//</my_ProjectCategoryURL>
		<my_RequestorEmail>test.person@testfacility.com</my_RequestorEmail>
		<my_AssignedPMEmail>test.person@testfacility.com</my_AssignedPMEmail>
		<my_CurrentUserName></my_CurrentUserName>
		<my_CurrentUserDisplayName></my_CurrentUserDisplayName>
		<my_UserIsApprover>true</my_UserIsApprover>
	</my_Variables>
</my_myFields>

 

 

My action looks like: 

xpath(xml(outputs('ComposeCleanXML2')), '/my_myFields/my_Requestor')

 

 

I'm getting this back and I have no idea what it means:

 

[
  {
    "$content-type": "application/xml;charset=utf-8",
    "$content": "PG15X1JlcXVlc3Rvcj4NCiAgPHBjX1BlcnNvbj4NCiAgICA8cGNfRGlzcGxheU5hbWU+QWx5c2hhIERyeXNkYWxlPC9wY19EaXNwbGF5TmFtZT4NCiAgICA8cGNfQWNjb3VudElZXJzaGlwfGFseXNoYS5kcnlzZGFsZUBhY2FkaWFoZWFsdGhjYXJlLmNvbTwvcGNfQWNjb3VudElkPg0KICAgIDxwY19BY2NvdW50VHlwZT48L3BjX0FjY291bnRUeXBlPg0KICA8L3BjX1BlcnNvbj4NCjwvbXlfUmVxdWVzdG9yPg=="
  }
]

 

 

I have no idea what to do with this though.

 

4 REPLIES 4
Highlighted
Dual Super User
Dual Super User

Re: Reading XML from Infopath file

Hi!

I faced a similar problem some time ago

Please check

https://powerusers.microsoft.com/t5/Building-Flows/Xpath-outputs-in-text-format/td-p/455127

https://powerusers.microsoft.com/t5/Building-Flows/Using-XPATH-over-XML-file-return-coded-anwer/td-p...

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted
Post Patron
Post Patron

Re: Reading XML from Infopath file

@efialttes I tried the first suggestion(adding string to the xpath function) but I just receive an error at that point.

 

xpath(xml(outputs('ComposeCleanXML2')), 'String(/my_myFields/my_Requestor)')

 

Unable to process template language expressions in action 'Compose_2' inputs at line '1' and column '2229': 'The XPath expression evaluates to a result of type 'Any' that is not supported. The expression must evaluate to a number, a string, a boolean, or a node set.'.

 

Trying to use the base64tostring gives me:
Unable to process template language expressions in action 'Compose' inputs at line '1' and column '2229': 'The template language function 'base64ToString' expects its parameter to be a string. The provided value is of type 'Array'. Please see https://aka.ms/logicexpressions#base64ToString for usage details.'.


I'm guessing because there's $content-type and $content. I'm not positive how to target the $content directly. Do I have to filter this out?

I feel like this is insanely complicated just to convert some XML to JSON.

Highlighted
Post Patron
Post Patron

Re: Reading XML from Infopath file

@efialttes I tried selecting the $content specifically with this:

base64ToString(outputs('Compose_2')?['$content'])

 

Then I get this:
InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '1' and column '2229': 'The template language expression 'base64ToString(outputs('Compose_2')?['$content'])' cannot be evaluated because property '$content' cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.'.

Highlighted
Dual Super User
Dual Super User

Re: Reading XML from Infopath file

Hi!

FRom your feedback, it looks outputs('Compose_2') is an array with a single element inside, so I would try with

base64ToString(first(outputs('Compose_2'))?['$content'])

 

or, if you expect more than one element, add an Apply to each, assign outputs('Compose_2') as its input and try the conversion inside it by means of the following expression:

base64ToString(item()?['$content'])

 

Better explained here

https://sharepains.com/2018/04/27/microsoft-flow-create-sharepoint-list-items-using-xml/

 

Not in my laptop, unable to test



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Helpful resources

Announcements
firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

Top Solution Authors
Top Kudoed Authors
Users online (5,571)