XML import format

4150
4
Jump to solution
01-08-2015 05:34 AM
DanielErklauer
New Contributor III

I am attempting to import an XML using the XML tool.  It imports the document  into excel without an issue but ESRI does not like it for some reason, I get the "ERROR 001162".  Can't seem to find much information on this topic or Error other than "The XML file is not correctly
formatted or is not a valid XML document type." I have tried several different version of acceptable XML indentation styles. Below is an example of what I am working with

 

<?xml version="1.0" encoding="UTF-8"?> <position-report-mail>     <time-offset>         <name>Time conversion</name>         <value>0</value>     </time-offset>     <trace-application>         <name>Trace application</name>         <value>System</value>     </trace-application>     <trace-identifier>         <name>Trace identifier</name>         <value>ats</value>     </trace-identifier>     <trace-address>         <name>Trace address</name>         <value/>     </trace-address>     <package-code>         <name>Sales package name</name>         <value>FLEET_PLUS</value>     </package-code>     <vessel>         <asset-type>             <name>Asset type</name>             <value>vessel</value>         </asset-type>         <vessel-code>             <name>Vessel code</name>             <value>PSF00032</value>         </vessel-code>         <vessel-name>             <name>Vessel name</name>             <value>Apollo</value>         </vessel-name>         <i-m-o-number>             <name>IMO number</name>             <value>6666666</value>         </i-m-o-number>         <call-sign>             <name>Call sign</name>             <value/>         </call-sign>         <flag-code>             <name>Flag</name>             <value/>         </flag-code>         <m-m-s-i>             <name>MMSI</name>             <value/>         </m-m-s-i>         <asset-parameter>             <name>Flag State</name>             <value>USA</value>         </asset-parameter>         <asset-parameter>             <name>Fuel IFO RBO</name>             <value>500000</value>         </asset-parameter>         <asset-parameter>             <name>Tracking</name>             <value>Every 240 minutes</value>         </asset-parameter>         <asset-parameter>             <name>Vessel Type</name>             <value>Bulk Carrier</value>         </asset-parameter>     </vessel>     <position-report>         <trail-date-time>             <name>Position date &amp; time</name>             <date-of-value>2014-09-08</date-of-value>             <time-of-value>17:09:09</time-of-value>         </trail-date-time>         <latitude>             <name>Latitude</name>             <degrees-of-value>41.0</degrees-of-value>             <minutes-of-value>35.0</minutes-of-value>             <seconds-of-value>16.8</seconds-of-value>             <hemisphere-of-value>north</hemisphere-of-value>         </latitude>         <longitude>             <name>Longitude</name>             <degrees-of-value>55.0</degrees-of-value>             <minutes-of-value>59.0</minutes-of-value>             <seconds-of-value>4.8</seconds-of-value>             <hemisphere-of-value>west</hemisphere-of-value>         </longitude>         <speed>             <name>Speed</name>             <value-of-value>21.48148148148148</value-of-value>             <units-of-value>KPH</units-of-value>         </speed>         <heading>             <name>Heading</name>             <value-of-value>241.0</value-of-value>             <units-of-value>DEGREES</units-of-value>         </heading>     </position-report> </position-report-mail>
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor

The Import XML Workspace Document tool takes a very specific format of the XML file in order for it to be work successfully.  You can take a look at the format by exporting a table/feature class to an XML using the Export XML Workspace Document tool. 

You would need to parse through this XML and insert the records into a table/feature class.  For example, you could use the xml.etree.ElementTree python module to parse the file and the arcpy.da.InsertCursor access module to update a table or feature class.

View solution in original post

4 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Daniel,

What does the XML represent that you are trying to import?  Is it a feature class, geodatabase table, etc?  When you say that you are using the XML tool, are you referring to the Import XML Workspace Document tool?

0 Kudos
DanielErklauer
New Contributor III

Jake thanks for getting back to me.  Yes I am referring to Import XML Workspace Document.  The XML is a table with a position in it lines 69-88 above (see below for clip) so I am trying to plot it as a point.

<latitude> 

  •             <name>Latitude</name> 
  •             <degrees-of-value>41.0</degrees-of-value> 
  •             <minutes-of-value>35.0</minutes-of-value> 
  •             <seconds-of-value>16.8</seconds-of-value> 
  •             <hemisphere-of-value>north</hemisphere-of-value> 
  •         </latitude> 
  •         <longitude> 
  •             <name>Longitude</name> 
  •             <degrees-of-value>55.0</degrees-of-value> 
  •             <minutes-of-value>59.0</minutes-of-value> 
  •             <seconds-of-value>4.8</seconds-of-value> 
  •             <hemisphere-of-value>west</hemisphere-of-value> 
0 Kudos
JakeSkinner
Esri Esteemed Contributor

The Import XML Workspace Document tool takes a very specific format of the XML file in order for it to be work successfully.  You can take a look at the format by exporting a table/feature class to an XML using the Export XML Workspace Document tool. 

You would need to parse through this XML and insert the records into a table/feature class.  For example, you could use the xml.etree.ElementTree python module to parse the file and the arcpy.da.InsertCursor access module to update a table or feature class.

DanielErklauer
New Contributor III

That's what I was looking for thanks

0 Kudos