MS Flow中如何用XPath提取XML的compassid值生成纯值数组?
Hey there! I see you're trying to pull the raw compassid values from your XML response in MS Flow, but right now you're getting those base64-encoded XML node objects instead. Let's fix that quickly.
Why Your Current XPath Isn't Working
The xpath() function in MS Flow returns XML node objects by default when you target element nodes (like /qdbapi/record/compassid), which is why you're seeing the $content-type and base64 $content fields. To get just the text inside those nodes, you need to adjust your XPath to target the text nodes directly.
Solution 1: Update Your XPath Expression
Modify your existing XPath to include /text() at the end, which tells the function to return the text content of the compassid elements instead of the elements themselves:
xpath(xml(body('CompassIDs')), '/qdbapi/record/compassid/text()')
This should return a clean array of pure values like:
["122542", "222222", "981344"]
Solution 2: Transform the Existing Result (If Solution 1 Doesn't Work)
For some edge cases, if you still end up with the node objects, you can use a Select action to convert them:
- Add a Select action to your flow.
- Set the From field to the output of your current
xpath()expression. - In the Map section, use this expression to decode the base64 content and extract the text:
xpath(xml(decodeBase64(item()?['$content'])), 'text()')[0] - The output of the
Selectaction will be your desired array of purecompassidvalues.
That should get you exactly what you need!
内容的提问来源于stack exchange,提问作者Mack Phillips

