Skip to main content
Solved

How can I parse XML data?


juanmahere
Supporter
Forum|alt.badge.img+11

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

View original
Did this help you find an answer to your question?

4 replies

hkingsbury
Celebrity
Forum|alt.badge.img+53
  • 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+11
  • Author
  • Supporter
  • August 3, 2022

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


juanmahere
Supporter
Forum|alt.badge.img+11
  • 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+53
  • Celebrity
  • August 4, 2022
juanmahere wrote:

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings