Skip to main content

I don't deal with writing XML very often (ever, really), so I'm struggling to do something and of course they need it yesterday. The vendor needs an export from my Esri database in XML format and I think the only thing I am missing is that my XML file (using the XML Writer) is writing "elements" instead of "attributes", so they say they can't import it. I can't for the life of me figure out what I need to do to achieve this without going down a very deep hole and learning XML in the next five minutes... Is there a setting I'm not understanding, or is it really that complicated? I don't need geometry, they just want to fill a table with my data.

XML can be complicated if they need a specific structure, but if they can give you a sample of what they (in terms of structure) want you should be able to use the XMLTemplater and write out your data in that structure.

The XML FAQ has some helpful hints.


XML values come in two flavours

Elements look like the following structure

<Name>Safe Software HQ</Name>
<Location>
   <Address>Suite 2017 7445 132nd St</Address>
   <City>Surrey</City>
   <Province>British Columbia</Province>
   <Country>Canada</Country>
   <PostalCode>V3W 1J8</PostalCode>
</Location>

Whereas attributes are like this

<Entry id="1" Name="Safe Software HQ" >

The xml writer defaults to elements.

Using the XMLTemplater is the way to go.


And combined to the XMLTemplater you want to use the TXT writer (not an XML writer)!

The output of the XMLTemplater should go in the attribute text_line_data of the TXT writer.

You may want to use the XMLFormatter before output to "Pretty Print" the XML attribute.


Yes, they did send me an example of an export! Thanks for the XMLTemplater suggestion. However, I am confused as to how I can use this example file as my template in the transformer? Do I simply leave one line in it with no attributes filled or something like that? Or do I have to generate a different kind of file from the example they sent? Thank you so much guys, I think I'm close...


Ooo, a text writer. That makes sense...


Yes, they did send me an example of an export! Thanks for the XMLTemplater suggestion. However, I am confused as to how I can use this example file as my template in the transformer? Do I simply leave one line in it with no attributes filled or something like that? Or do I have to generate a different kind of file from the example they sent? Thank you so much guys, I think I'm close...

Copy the XML example file in the XML Templater and substitute values in the XML with attributes from the features going into the XMLTemplater. Just drag and drop from the left side panel.


Copy the XML example file in the XML Templater and substitute values in the XML with attributes from the features going into the XMLTemplater. Just drag and drop from the left side panel.

So I'm not using the example xml file directly as an import, I'm just using it on the side to get the field names? I see now where you can build those XQueries, but I was hoping I could use it more directly as it seemed to suggest by allowing you to choose a file in the first place. But I think I see now that the ROOT port option to use a file assumes you have those XQueries in that file, not that can build the XQueries for you from that file. If that makes sense...I think I'm getting there...

Thank you so much for TXT file suggestion, the format of each record is perfect now. Now I just have to get the attribute values in there!


Reply