Skip to main content
Solved

Extracting data using the XML Flattener

  • September 28, 2020
  • 5 replies
  • 213 views

nedwaterman
Contributor
Forum|alt.badge.img+9

fmeHi,

 

I'm trying to use the XML Flattener to extract the attributes from an xml response_body:

 

<loggers>

<summary>

<APIVersion>DatagateAdmin V2.48 (14-Sep-2020 12:38)</APIVersion>

<accountID>5279</accountID>

<accountName>Main Account for all SWW loggers</accountName>

<accountOwnerId></accountOwnerId>

<accountHighestMessage>4526752363</accountHighestMessage>

<accountUpdateTime>2020-09-28 08:39:17.6</accountUpdateTime>

<accountNumLoggers>2563</accountNumLoggers>

<CentreLongitude>-3.86433819774539</CentreLongitude>

<CentreLatitude>50.6236029248117</CentreLatitude>

<MinimumPhoto>0</MinimumPhoto>

</summary>

<logger>

<loggerid>74508</loggerid>

<mobileNumber>447924658356</mobileNumber>

<dateLastMessageReceived>2019-12-17 16:00:00.0</dateLastMessageReceived>

<type>FW-102-001</type>

<serialNumber>80823</serialNumber>

<loggerOwner>5279</loggerOwner>

<LogRate></LogRate>

<RST>2019-02-05 12:30:00.0</RST>

<RET>0001-01-01 00:00:00.0</RET>

<gsmDataNumber>0</gsmDataNumber>

<notes></notes>

<batteryCondition>0</batteryCondition>

<signalStrength>0</signalStrength>

<lastReportedVersion>3.90</lastReportedVersion>

<dateCreated>2015-09-29 09:41:00.0</dateCreated>

<dateUpdated>2018-11-16 16:40:36.6</dateUpdated>

<heightAOD>99.0</heightAOD>

<startDate>2015-09-29 00:00:00.0</startDate>

<endDate>2020-10-04 00:00:00.0</endDate>

<maintenanceflag>False</maintenanceflag>

<id>74508</id>

<owner>5279</owner>

<siteId>1201</siteId>

<siteName>Sweyns Lease PCC</siteName>

<SiteNotes></SiteNotes>

<latitude>50.805459823648</latitude>

<longitude>-1.469778435546914</longitude>

<channel1Type></channel1Type>

<flowPulseFactor1>0.1</flowPulseFactor1>

<meterRead1Value>0</meterRead1Value>

<meterRead1Date>0001-01-01 00:00:00.0</meterRead1Date>

<channel2Type></channel2Type>

<flowPulseFactor2>1</flowPulseFactor2>

<meterRead2Value>0</meterRead2Value>

<meterRead2Date>0001-01-01 00:00:00.0</meterRead2Date>

<channels>

<channel number="1">

<channelName></channelName>

<offset>0</offset>

<flowPulseFactor>0.1</flowPulseFactor>

<meterReadValue>0</meterReadValue>

<meterReadDate>0001-01-01 00:00:00.0</meterReadDate>

<calvalue>0.1</calvalue>

<loggercalvalue>0.1</loggercalvalue>

<loggeroffset>0</loggeroffset>

<ignoreloggervalues>0</ignoreloggervalues>

<is4to20>0</is4to20>

<loggerIs4to20>0</loggerIs4to20>

<invertnegativevalues>0</invertnegativevalues>

<lastValue>27.4</lastValue>

<lastValueDate>2019-12-17 12:30:00.0</lastValueDate>

<measurement id = "0">

<name></name>

<reference></reference>

<units>

<symbols>m</symbols>

</units>

</measurement>

</channel>

</logger>

 

I'm using these parameters in the XML Flattener to grab the loggers.logger.loggerid but its not working:

 

Any idea what I am doing wrong? I'm aware that there are multple logger values so have also tried loggerid{}, loggerid{*} but neither work.

 

Thanks

Neil

Best answer by ebygomm

nedwaterman wrote:

Hi David

Thank you - however, its only produced a single record rather than all the loggerid's in the xml response. Does FME make a list of these I need to expose?

If you want multiple features, I'd use the XMLFragmenter rather than the XMLFlattener

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

5 replies

david_r
Celebrity
  • September 28, 2020

Have you tried setting Elements to Match to "logger" rather than "loggers"?

That should give you one FME feature per logger instance.


nedwaterman
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • September 28, 2020

Hi David

Thank you - however, its only produced a single record rather than all the loggerid's in the xml response. Does FME make a list of these I need to expose?


ebygomm
Influencer
Forum|alt.badge.img+38
  • Influencer
  • Best Answer
  • September 28, 2020
nedwaterman wrote:

Hi David

Thank you - however, its only produced a single record rather than all the loggerid's in the xml response. Does FME make a list of these I need to expose?

If you want multiple features, I'd use the XMLFragmenter rather than the XMLFlattener


nedwaterman
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • September 28, 2020
ebygomm wrote:

If you want multiple features, I'd use the XMLFragmenter rather than the XMLFlattener

I have been, but I need to extract data from twodifferent elements in the api: <logger> and <channel>. They are both children of <loggers> but the joining field <loggerid> only appears in <logger> and not <channel> so I can't join the data back to one row

 

 


david_r
Celebrity
  • September 28, 2020
ebygomm wrote:

If you want multiple features, I'd use the XMLFragmenter rather than the XMLFlattener

If you flatten the Logger elements, the channels will be present as "sub-attributes" using dot-notation, or as a list if there are several of them.

To see how this works, send the output of the XMLFragmenter to the Inspector and click on a feature to look at the Feature Information. The attributes visible here are the ones you'll need to expose in the XMLFragmenter.

Example:

2020-09-28 12_04_13-FME Data Inspector - 2020.1

 


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