Skip to main content
Solved

How can I parse XML data?

  • August 2, 2022
  • 4 replies
  • 308 views

juanmahere
Supporter
Forum|alt.badge.img+13

Hi,

New in XML transformers, I'd like to know in FME Desktop 2022 how can I read and parse data contained on this XML:

 

<SOAP-ENV:Envelope>
<SOAP-ENV:Body>
<ns1:GetSiteValuesResponse>
<ns1:siteValues>
<ns1:siteRAIId>1558</ns1:siteRAIId>
<ns1:x>144.882271794492</ns1:x>
<ns1:y>-37.825548770183602</ns1:y>
<ns1:enabled>true</ns1:enabled>
<ns1:reportedTime>2022-07-26T23:58:04.878</ns1:reportedTime>
<ns1:currentValues>
<ns1:laneNumber>1</ns1:laneNumber>
<ns1:panelValue>Blank</ns1:panelValue>
<ns1:annulusFlashing>false</ns1:annulusFlashing>
</ns1:currentValues>
<ns1:currentValues>
<ns1:laneNumber>2</ns1:laneNumber>
<ns1:panelValue>Blank</ns1:panelValue>
<ns1:annulusFlashing>false</ns1:annulusFlashing>
</ns1:currentValues>
<ns1:currentValues>
<ns1:laneNumber>3</ns1:laneNumber>
<ns1:panelValue>Blank</ns1:panelValue>
<ns1:annulusFlashing>false</ns1:annulusFlashing>
</ns1:currentValues>
<ns1:currentValues>
<ns1:laneNumber>4</ns1:laneNumber>
<ns1:panelValue>Blank</ns1:panelValue>
<ns1:annulusFlashing>false</ns1:annulusFlashing>
</ns1:currentValues>
<ns1:previousValues>
<ns1:laneNumber>1</ns1:laneNumber>
<ns1:panelValue>Unknown</ns1:panelValue>
<ns1:annulusFlashing>false</ns1:annulusFlashing>
</ns1:previousValues>
<ns1:previousValues>
<ns1:laneNumber>2</ns1:laneNumber>
<ns1:panelValue>Unknown</ns1:panelValue>
<ns1:annulusFlashing>false</ns1:annulusFlashing>
</ns1:previousValues>
<ns1:previousValues>
<ns1:laneNumber>3</ns1:laneNumber>
<ns1:panelValue>Unknown</ns1:panelValue>
<ns1:annulusFlashing>false</ns1:annulusFlashing>
</ns1:previousValues>
<ns1:previousValues>
<ns1:laneNumber>4</ns1:laneNumber>
<ns1:panelValue>Unknown</ns1:panelValue>
<ns1:annulusFlashing>false</ns1:annulusFlashing>
</ns1:previousValues>
</ns1:siteValues>
<ns1:siteValues>

(sorry if its not the best way to Copy&Paste code).

My intention is to extract data and convert into points using the x,y and the rest of attributes.

Btw, the XML is taken from a HTTPCaller.

 

Thanks in advance!

J.

Best answer by hkingsbury

The XML supplied is incomplete, but passing it into an XMLFlattener with the Elements to Match set to "*" will produce an FME list from the XML, from which you can then go and explode/expose/extract the relevant values

image

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

hkingsbury
Celebrity
Forum|alt.badge.img+65
  • Celebrity
  • Best Answer
  • August 2, 2022

The XML supplied is incomplete, but passing it into an XMLFlattener with the Elements to Match set to "*" will produce an FME list from the XML, from which you can then go and explode/expose/extract the relevant values

image


juanmahere
Supporter
Forum|alt.badge.img+13
  • Author
  • Supporter
  • August 3, 2022

Many thanks @hkingsbury​ ! I can proceed now with the List. Wise "*" tip. ;)


juanmahere
Supporter
Forum|alt.badge.img+13
  • Author
  • Supporter
  • August 3, 2022

When using the "*", I can have these properties,

Propertiesbut it is not a FME List, so, how could I explode into features based on those "indexes"?

Thanks,


hkingsbury
Celebrity
Forum|alt.badge.img+65
  • Celebrity
  • August 4, 2022

When using the "*", I can have these properties,

Propertiesbut it is not a FME List, so, how could I explode into features based on those "indexes"?

Thanks,

You'll need to expose those attributes using the AttributeExposer (or specifying them in the XMLFlattener). To expose at that level you'll need to expose "Body.GetSiteValuesResponse.SiteValues{}" - the "{}" indicates its a list. This will then make it show up as a list to transformers. You'll then need to also expose any other attributes you want to work with