Skip to main content
Solved

Reading XML as output from ZipExtractor


lambertus
Enthusiast
Forum|alt.badge.img+15

Using a HTTPcaller I downloaded a Zipfile which contains a XML. Using a FeatureReader I retrieved the path of the XML file. Furthermore the FeatureReader was used to read this XML using 'path_windows' as attribute which contains the XML file. However, I got stuck there.

 

In case I read the XML directly using a XML reader it works perfectly.

See the attached screenshot for my workflow.

Best answer by nielsgerrits

lambertus wrote:

Okay, hence it is not possible to read XML in the middle of a workflow ?

I set my FeatureReaders to SingleOutput port but that does not make a difference.

It depends 😃 If your schema is fixed, it is perfectly doable:

  • In the FeatureReader XML reader, select a sample file in Dataset.
  • In the Parameters, select the elements to match. (Assuming you use Feature Paths.)
  • Set Output Ports to Single Output Port. *
  • Test if this works as expected.
  • Now change FeatureReader XML reader Dataset to path_windows.

* You can choose to set Output Ports to One per Feature Type, but then you need to select the sample file every single time you make a change to the FeatureReader, to populate the outputports. And that quickly becomes annoying in my book.

 

Another way of dynamically processing XML is to use a Text Reader (Read Whole File at Once = Yes) and process the attribute with the XML using XMLFragmenters.

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

5 replies

nielsgerrits
VIP
Forum|alt.badge.img+54

Are you sure the file is still there? Because you are using FeatureCaching, you can remove the extracted zip using the explorer without workbench knowing it.


lambertus
Enthusiast
Forum|alt.badge.img+15
  • Author
  • Enthusiast
  • May 6, 2021
nielsgerrits wrote:

Are you sure the file is still there? Because you are using FeatureCaching, you can remove the extracted zip using the explorer without workbench knowing it.

Hi niels, yeah I see it popping up in my explorer when running the workspace. Maybe it has to do with my settings of the 2nd FeatureReader (reading XML). I clicked 'Feature Types to Read' and got an error.

 

Error FME XML reader 

However, reading the same XML with a seperate XML reader works fine:

 

Reading XML with XML reader


nielsgerrits
VIP
Forum|alt.badge.img+54
lambertus wrote:

Hi niels, yeah I see it popping up in my explorer when running the workspace. Maybe it has to do with my settings of the 2nd FeatureReader (reading XML). I clicked 'Feature Types to Read' and got an error.

 

Error FME XML reader 

However, reading the same XML with a seperate XML reader works fine:

 

Reading XML with XML reader

This should really work. The error is because the Dataset is an attribute instead of a value, so it can't scan for a schema, so you can't choose from scanned featuretypes.

Did you set the FeatureReaders OutputPorts to Single Output Port?


lambertus
Enthusiast
Forum|alt.badge.img+15
  • Author
  • Enthusiast
  • May 6, 2021

Okay, hence it is not possible to read XML in the middle of a workflow ?

I set my FeatureReaders to SingleOutput port but that does not make a difference.


nielsgerrits
VIP
Forum|alt.badge.img+54
lambertus wrote:

Okay, hence it is not possible to read XML in the middle of a workflow ?

I set my FeatureReaders to SingleOutput port but that does not make a difference.

It depends 😃 If your schema is fixed, it is perfectly doable:

  • In the FeatureReader XML reader, select a sample file in Dataset.
  • In the Parameters, select the elements to match. (Assuming you use Feature Paths.)
  • Set Output Ports to Single Output Port. *
  • Test if this works as expected.
  • Now change FeatureReader XML reader Dataset to path_windows.

* You can choose to set Output Ports to One per Feature Type, but then you need to select the sample file every single time you make a change to the FeatureReader, to populate the outputports. And that quickly becomes annoying in my book.

 

Another way of dynamically processing XML is to use a Text Reader (Read Whole File at Once = Yes) and process the attribute with the XML using XMLFragmenters.


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