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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Issues with XPath in flow
Power Automate
Unanswered

Issues with XPath in flow

(0) ShareShare
ReportReport
Posted on by 15

Hello,

 

We recently ran into an issue where we have lost an InfoPath form containing necessary information and I am attempting to see if we can use flow to recover some of it.   We have the xml files so we have all the data necessary but anytime we attempt to put in any xpath query we get an error.

 

here is an example of an xml file we are attempting to get data out of.

<?xml version="1.0"?><?mso-infoPathSolution name="urn:schemas-microsoft-com: office:infopath:AccRept-2013-14:-myXSD-2012-08-08T17-37-13" solutionVersion="1.0.0.443" productVersion="14.0.0.0" PIVersion="1.0.0.0" href="https://portal1.cbsd.org/WorkflowForms/AccRept_201314/Forms/template.xsn"?><?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?><my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls" 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:xhtml="http://www.w3.org/1999/xhtml" xmlns:tns="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:soap="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/2012-08-08T17:37:13" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-US">
	<my:Building></my:Building>
	<my:ReportDate></my:ReportDate>
	<my:FormSubmitter></my:FormSubmitter>
	<my:AccidentDetails>
		<my: Student>true</my: Student>
		<my: Other>false</my: Other>
		<my: OtherSpecify></my: OtherSpecify>
		<my:LastName></my:LastName>
		<my:FirstName></my:FirstName>
		<my:Male></my:Male>
		<my:Female></my:Female>
		<my:HomePhone></my:HomePhone>
		<my:Grade></my:Grade>
		<my:Homeroom></my:Homeroom>
		<my: SchoolBuilding></my: SchoolBuilding>
		<my: SchoolGrounds></my: SchoolGrounds>
		<my: OffPremises></my: OffPremises>
		<my: SpecificLocation></my: SpecificLocation>
		<my: DateTimeAccident></my: DateTimeAccident>
		<my: DateTimeReported></my: DateTimeReported>
		<my:ActivityTimeofAccident></my:ActivityTimeofAccident>
		<my:InjuryDescription></my:InjuryDescription>
	</my:AccidentDetails>
	<my: Disposition>
		<my:Yes_FirstAid></my:Yes_FirstAid>
		<my:No_FirstAid></my:No_FirstAid>
		<my:TreatedBy></my:TreatedBy>
		<my:TreatedByPosition></my:TreatedByPosition>
		<my:NatureOfTreatment></my:NatureOfTreatment>
		<my:ReferredToNurse></my:ReferredToNurse>
		<my:ReferredToPhysician></my:ReferredToPhysician>
		<my:ReferredToHospital></my:ReferredToHospital>
		<my:ReferredToOther></my:ReferredToOther>
		<my: DateTimeReferredToNurse></my: DateTimeReferredToNurse>
		<my: DateTimeReferredToPhysician xsi:nil="true"></my: DateTimeReferredToPhysician>
		<my: DateTimeReferredToHospital xsi:nil="true"></my: DateTimeReferredToHospital>
		<my: DateTimeReferredToOther xsi:nil="true"></my: DateTimeReferredToOther>
		<my: PhysicianName></my: PhysicianName>
		<my:HospitalName></my:HospitalName>
		<my: DateTimeParentsNotified></my: DateTimeParentsNotified>
		<my: PersonNotifyingParents></my: PersonNotifyingParents>
		<my:NurseFollowUp></my:NurseFollowUp>
		<my:AdditionalTreatment></my:AdditionalTreatment>
	</my: Disposition>
	<my: SubmitApprove>
		<my:group_3></my:group_3>
		<my:group_4></my:group_4>
		<my:NurseEmail></my:NurseEmail>
		<my:AdminEmail></my:AdminEmail>
	</my: SubmitApprove>
	<my:Reviewed>
		<my:NurseReview>
			<my:NurseName></my:NurseName>
			<my:NurseReviewDate xsi:nil="true"></my:NurseReviewDate>
			<my:NurseReviewed></my:NurseReviewed>
		</my:NurseReview>
		<my:AdminReview>
			<my:AdminName></my:AdminName>
			<my:AdminReviewDate xsi:nil="true"></my:AdminReviewDate>
			<my:AdminReviewed></my:AdminReviewed>
		</my:AdminReview>
	</my:Reviewed>
	<my:HiddenFields>
		<my:AccidentFormStatus></my:AccidentFormStatus>
		<my:WhenCreated xsi:nil="true"></my:WhenCreated>
		<my:ApproverNumber></my:ApproverNumber>
		<my:NextFormApprover></my:NextFormApprover>
		<my:CurrentApprover></my:CurrentApprover>
	</my:HiddenFields>
</my:myFields>

There is data in the file but due to confidentiality reasons I removed it from the post.  The issue I get is when I attempt to run any xpath flow expressions to pull data I always get an error.  For example in order  to pull home phone I have attempted.

xpath(xml(body('Get_file_content')),'string(my:myFields/my:AccidentDetails/my:HomePhone)')

xpath(xml(body('Get_file_content')),'my:myFields/my:AccidentDetails/my:HomePhone')

xpath(xml(body('Get_file_content')),'//my:HomePhone')

in every instance I get an error.  I have tested all these on a free online xpath query tester and they all return the value I need it, the issue only seems to be with flow itself.  Is there something wrong with my xpath or can this not be done with flow.

 

*Edit:  I added spaces in a few xml nodes to prevent them from being viewed as emoji's.

Categories:
I have the same question (0)
  • v-yamao-msft Profile Picture
    on at

    Hi @dwhittaker82 ,

     

    What’s the error message returned?

    I have made the following test, please check it for a reference.

    Trigger the flow by a button.

    Add Compose action, input the following code:

     

    <Countries>
    
              <Country type="System.String">China</Country>
    
              <Country type="System.String">Japan</Country >
    
             </Countries>

     

    Add Compose 2:

    xpath(xml(outputs('Compose')),'//Country')

    Add an Apply to each, select value from Compose 2, then add a Compose within the Apply to each:

    xpath(xml(item()),'string(.)')

    Then run the flow you will get the countries likes below:

    1.PNG2.PNG

     

    Best regards,

    Mabel

     

  • dwhittaker82 Profile Picture
    15 on at

    For the most part the errors were just generic 'xpath must be a supported, well formed XPath expression'.  Which was weird because every XPath tester I tried viewed each statment as well formed and found the data I want,  the issue seemed to specifically be with flow.  I was able to get it to work using this expression,

     

    /*[name()="my:myFields"]

    but I didn't test going any deeper then the <my:myFields> node.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard