2

I want the below xml file to be read by fme.

I tried reading documents and seeing videos. This xml looks more complicated.

http://pastebin.com/pXmjwEqW

<InspectObjects>
<Object id="197589" action="update" objectType="pole" DataSetName="electric"     UniverseId="0" WorldId="0">
<Attributes>
<Attribute id="asset_id"></Attribute>
<Attribute id="id">197589</Attribute>
<Attribute id="location_description">A.T.L.</Attribute>
<Attribute id="npcl_ct">False</Attribute>

I have different objects in a single xml file. I want to filter based on "objectType".

How this can be done by using xml parsing in FME?

  • pastebin is blocked (at work) but been doing lots of xml parsing in FME lately can you put a snippet in your question please. – Mapperz Jun 29 '15 at 14:06
  • Please see the edited. – User123 Jun 30 '15 at 4:29
3

To extract the attributes you need the xmlflattener

"Flattens content of XML element(s) into feature attributes.

This transformer provides a quick and easy way to output any content or attributes of an XML element as feature attributes by specifying the element name or path. Optionally, the XML attributes from the ancestors of the specified elements can be fetched as FME attributes as well."

A good reference https://knowledge.safe.com/articles/Samples_and_Demos/Reading-Complex-XML-or-GML-using-the-XMLFlattener

  • Great Thanks. Really informative and helpful. Will check and let you know. – User123 Jul 1 '15 at 15:20
2

As mentioned in a previous answer, use the XMLFlattener. In the the Expose Attributes parameter of the transformer, be sure to expose the "Object.objectType" attribute (you can rename the attribute with the AttributeRenamener if you like) You can then use filtering and testing transformers on this new attribute.

This looks like FieldSmart XML. It is not clear what are you doing with the data.

2

Now FME has made it very easy to extract the XML (and Json) elements at the reader level. This is just an update since the question was asked in 2015 and the latest version of FME is 2018.

enter image description here

You could flatten your file here as well

enter image description here

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.