Skip to main content

Hi, Can someone advise whether this is possible? Im looking to use Excel to edit an xml file and want to use FME to perform the exchange. I can see an xml reader and writer to excel, but cant work out the return. Am I hoping for too much?

Xml file below

Hi @cfordigan, if the Excel table satisfies these conditions:

  • has 3 columns (FamilyName, NewTypeName, TypeName) corresponding to the child elements of <WallList> element,
  • the number of records is equal to the number of <WallList> elements,
  • the order of the records matches the order of <WallList> elements,

the XMLUpdater in this workflow might work for you.

Hope this helps.


Hi @cfordigan, if the Excel table satisfies these conditions:

  • has 3 columns (FamilyName, NewTypeName, TypeName) corresponding to the child elements of <WallList> element,
  • the number of records is equal to the number of <WallList> elements,
  • the order of the records matches the order of <WallList> elements,

the XMLUpdater in this workflow might work for you.

Hope this helps.

XML to Excel

 

 


I just wanted to add one other approach which might make this process easier if you have a lot of fields to update or the XML structure gets more complex. To clarify for XML reading, we have a new tree control that lets you browse your source XML structure and select the element that you want to become a feature type. This takes the guess work out of composing the feature path. The default flattening setting will then yield records for all WallList elements with child elements interpreted as attributes. It looks like Takashi used this same approach for reading.

0684Q00000ArKj2QAF.png

For more examples and explanation see the XML Tutorial at: https://knowledge.safe.com/articles/28309/tutorial-getting-started-with-xml-reading.html

An alternative way to go from Excel or table form back to XML is to use XMLTemplater and the Text File writer. The XMLTemplater requires XML templates that provide the structure to use for the dataset and feature elements. A WallList XML record sub-template, which merges FME attributes back into an XML document, could look something like this:

<WallList> 
<FamilyName>{fme:get-attribute("FamilyName")}</FamilyName>
<TypeName>{fme:get-attribute("TypeName")}</TypeName> 
<NewTypeName>{fme:get-attribute("NewTypeName")}</NewTypeName>
</WallList>

The dataset template might look like this:

<NewDataSet>
   <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
   </xs:schema>
   {fme:process-features("SUB")}
</NewDataSet>

The trick is to feed the dataset template record (one per dataset) into the Root input of the XMLTemplater and the WallList records into the SUB input port.

There is a complete example of this in the same XML tutorial:  https://knowledge.safe.com/articles/30940/xml-writing-with-xmltemplater.html


Reply