Skip to main content

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

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

That should give you one FME feature per logger instance.


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?


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


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

 

 


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

 


Reply