{"id":168331,"date":"2010-05-07T17:22:01","date_gmt":"2010-05-08T00:22:01","guid":{"rendered":"http:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=168331"},"modified":"2018-12-18T11:34:17","modified_gmt":"2018-12-18T19:34:17","slug":"handling-xml-with-python-in-arcgis","status":"publish","type":"blog","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis","title":{"rendered":"Handling XML with Python in ArcGIS"},"author":4031,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"_acf_changed":false,"_searchwp_excluded":""},"categories":[23341,23851],"tags":[31181,24321,28101,24341],"industry":[],"product":[36991],"class_list":["post-168331","blog","type-blog","status-publish","format-standard","hentry","category-analytics","category-data-management","tag-arcpy","tag-geoprocessing","tag-gps","tag-python","product-arcgis-desktop"],"acf":{"short_description":"The Python language offers a variety of ways to handle and parse XML. Lots of GIS data can be stored in an XML schema. ","flexible_content":[{"acf_fc_layout":"content","content":"<p>The Python language offers a variety of ways to handle and parse XML. Lots of GIS data can be stored in an XML schema. For example, KML is made up of a well known XML structure. Another well known structure includes GPX, the native format that GPS devices typically save too. By using Python and\u00a0<a class=\"\" title=\"ArcPy\" href=\"http:\/\/help.arcgis.com\/en\/arcgisdesktop\/10.0\/help\/index.html#\/What_is_ArcPy\/000v000000v7000000\/\" target=\"_blank\" rel=\"noopener\">ArcPy<\/a>, you can create features from XML.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/downloads2.esri.com\/blogs\/images\/dev_12841.jpg\" width=\"396\" height=\"340\" align=\"right\" border=\"0\" \/>One of my teammates on the Geoprocessing team recently invested in a GPS sports watch. In addition to telling time, his watch could track movement and monitor heart rate. Since we love geography, programming, geoprocessing and fitness so much, another teammate, Ghislain, took to writing a tool to turn the GPX (XML) into feature classes for display on a map. A closer inspection of the GPS output and a look into the schema provided by\u00a0<i>topographix<\/i>(<a href=\"http:\/\/www.topografix.com\/gpx\/1\/1\/\">http:\/\/www.topografix.com\/gpx\/1\/1\/<\/a>) shows that the XML follows a standard format on how latitude, longitude, elevation and time are saved. This particular schema is enhanced to save the heart rate information. Since the information is saved in an expected way, one Python script could be written to handle many different GPS outputs.<\/p>\n<p>Ghislain looked into the Python class ElementTree. ElementTree has many easy to use functions to parse through XML. Python also has other objects like Minidom or XPath which can be used to read XML; however, for this script ElementTree was used. The script looks for the values mentioned previously and hands this information over to an\u00a0<a class=\"\" title=\"ArcPy Cursor\" href=\"http:\/\/help.arcgis.com\/en\/arcgisdesktop\/10.0\/help\/index.html#\/InsertCursor\/000v00000038000000\/\" target=\"_blank\" rel=\"noopener\">ArcPy cursor<\/a>\u00a0which writes the information into a point feature class.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/downloads2.esri.com\/blogs\/images\/dev_12843.jpg\" border=\"0\" \/><\/p>\n<p>The complete script is available in the\u00a0<a class=\"\" title=\"Model and Script Gallery\" href=\"http:\/\/resources.arcgis.com\/gallery\/file\/geoprocessing\" target=\"_blank\" rel=\"noopener\">Model and Script Gallery<\/a>:\u00a0<a class=\"\" title=\"GPS to Layer Tool\" href=\"http:\/\/resources.arcgis.com\/gallery\/file\/geoprocessing\/details?entryID=73DDDDC4-1422-2418-7F82-92D8B8ED294B\" target=\"_blank\" rel=\"noopener\">GPS to Layer<\/a>. Feel free to take it and use it simply to convert your GPX points into a feature class, or break it open and look at how Python can be used in your ArcGIS workflows. Use the comments section here or\u00a0on the page itself to leave any feedback on this tool.<\/p>\n<p>Well, what good would this GPS to Points tool be if we didn\u2019t use it to evaluate the fitness level of our co-worker? Based on the map show below there is a lot of orange and red, and I\u2019m concerned with a heart rate of 200 beats per minute on the uphill, but according to\u00a0<a class=\"\" href=\"http:\/\/en.wikipedia.org\/wiki\/File:Exercise_zones.png\" target=\"_blank\" rel=\"noopener\">Wikipedia<\/a>, he just must be giving his \u201cmaximum effort\u201d. At least his maximum effort is an honest effort!<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/downloads2.esri.com\/blogs\/images\/dev_12842.jpg\" border=\"0\" \/><\/p>\n<p><b>Additional Resources:<\/b><br \/>\n\u2022\u00a0An excellent blog post by Doug Hellmann\u00a0<a href=\"http:\/\/blog.doughellmann.com\/2010\/03\/pymotw-parsing-xml-documents-with.html\">http:\/\/blog.doughellmann.com\/2010\/03\/pymotw-parsing-xml-documents-with.html<\/a>\u00a0explains different ways to walk through XML.<br \/>\n\u2022\u00a0Python 2.6.x XML ElementTree documentation,\u00a0<a href=\"http:\/\/docs.python.org\/library\/xml.etree.elementtree.html\">http:\/\/docs.python.org\/library\/xml.etree.elementtree.html<\/a><br \/>\n\u2022\u00a0Element Tree Overview from effbot.org,\u00a0<a href=\"http:\/\/effbot.org\/zone\/element-index.htm\">http:\/\/effbot.org\/zone\/element-index.htm<\/a><\/p>\n"}],"authors":[{"ID":4031,"user_firstname":"Kevin","user_lastname":"Hibma","nickname":"Kevin Hibma","user_nicename":"khibma","display_name":"Kevin Hibma","user_email":"khibma@esri.com","user_url":"","user_registered":"2018-03-02 00:15:39","user_description":"Kevin Hibma has almost two decades of experience building Esri software and works as a product engineer on the ArcGIS Enterprise team.","user_avatar":"<img data-del=\"avatar\" src='https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2024\/07\/kevinhibmaBlog300-213x200.jpg' class='avatar pp-user-avatar avatar-96 photo ' height='96' width='96'\/>"}],"related_articles":"","card_image":false,"wide_image":false},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Handling XML with Python in ArcGIS<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Handling XML with Python in ArcGIS\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis\" \/>\n<meta property=\"og:site_name\" content=\"ArcGIS Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/esrigis\/\" \/>\n<meta property=\"article:modified_time\" content=\"2018-12-18T19:34:17+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@ESRI\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis\"},\"author\":{\"name\":\"Kevin Hibma\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/e7c86c9932f187db7ea7c20449e7bf64\"},\"headline\":\"Handling XML with Python in ArcGIS\",\"datePublished\":\"2010-05-08T00:22:01+00:00\",\"dateModified\":\"2018-12-18T19:34:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis\"},\"wordCount\":6,\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"keywords\":[\"ArcPy\",\"geoprocessing\",\"GPS\",\"python\"],\"articleSection\":[\"Analytics\",\"Data Management\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis\",\"name\":\"Handling XML with Python in ArcGIS\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\"},\"datePublished\":\"2010-05-08T00:22:01+00:00\",\"dateModified\":\"2018-12-18T19:34:17+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.esri.com\/arcgis-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Handling XML with Python in ArcGIS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/\",\"name\":\"ArcGIS Blog\",\"description\":\"Get insider info from Esri product teams\",\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.esri.com\/arcgis-blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\",\"name\":\"Esri\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png\",\"contentUrl\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png\",\"width\":400,\"height\":400,\"caption\":\"Esri\"},\"image\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/esrigis\/\",\"https:\/\/x.com\/ESRI\",\"https:\/\/www.linkedin.com\/company\/5311\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/e7c86c9932f187db7ea7c20449e7bf64\",\"name\":\"Kevin Hibma\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2024\/07\/kevinhibmaBlog300-213x200.jpg\",\"contentUrl\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2024\/07\/kevinhibmaBlog300-213x200.jpg\",\"caption\":\"Kevin Hibma\"},\"description\":\"Kevin Hibma has almost two decades of experience building Esri software and works as a product engineer on the ArcGIS Enterprise team.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/kevin-hibma-48763610\/\"],\"url\":\"\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Handling XML with Python in ArcGIS","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis","og_locale":"en_US","og_type":"article","og_title":"Handling XML with Python in ArcGIS","og_url":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis","og_site_name":"ArcGIS Blog","article_publisher":"https:\/\/www.facebook.com\/esrigis\/","article_modified_time":"2018-12-18T19:34:17+00:00","twitter_card":"summary_large_image","twitter_site":"@ESRI","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis#article","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis"},"author":{"name":"Kevin Hibma","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/e7c86c9932f187db7ea7c20449e7bf64"},"headline":"Handling XML with Python in ArcGIS","datePublished":"2010-05-08T00:22:01+00:00","dateModified":"2018-12-18T19:34:17+00:00","mainEntityOfPage":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis"},"wordCount":6,"publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"keywords":["ArcPy","geoprocessing","GPS","python"],"articleSection":["Analytics","Data Management"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis","url":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis","name":"Handling XML with Python in ArcGIS","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#website"},"datePublished":"2010-05-08T00:22:01+00:00","dateModified":"2018-12-18T19:34:17+00:00","breadcrumb":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/arcgis-desktop\/analytics\/handling-xml-with-python-in-arcgis#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.esri.com\/arcgis-blog\/"},{"@type":"ListItem","position":2,"name":"Handling XML with Python in ArcGIS"}]},{"@type":"WebSite","@id":"https:\/\/www.esri.com\/arcgis-blog\/#website","url":"https:\/\/www.esri.com\/arcgis-blog\/","name":"ArcGIS Blog","description":"Get insider info from Esri product teams","publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.esri.com\/arcgis-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization","name":"Esri","url":"https:\/\/www.esri.com\/arcgis-blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png","contentUrl":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png","width":400,"height":400,"caption":"Esri"},"image":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/esrigis\/","https:\/\/x.com\/ESRI","https:\/\/www.linkedin.com\/company\/5311\/"]},{"@type":"Person","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/e7c86c9932f187db7ea7c20449e7bf64","name":"Kevin Hibma","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/","url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2024\/07\/kevinhibmaBlog300-213x200.jpg","contentUrl":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2024\/07\/kevinhibmaBlog300-213x200.jpg","caption":"Kevin Hibma"},"description":"Kevin Hibma has almost two decades of experience building Esri software and works as a product engineer on the ArcGIS Enterprise team.","sameAs":["https:\/\/www.linkedin.com\/in\/kevin-hibma-48763610\/"],"url":""}]}},"text_date":"May 7, 2010","author_name":"Kevin Hibma","author_page":false,"custom_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2025\/08\/Newsroom-Keyart-Wide-1920-x-1080.jpg","primary_product":"ArcMap","tag_data":[{"term_id":31181,"name":"ArcPy","slug":"arcpy","term_group":0,"term_taxonomy_id":31181,"taxonomy":"post_tag","description":"","parent":0,"count":32,"filter":"raw"},{"term_id":24321,"name":"geoprocessing","slug":"geoprocessing","term_group":0,"term_taxonomy_id":24321,"taxonomy":"post_tag","description":"","parent":0,"count":129,"filter":"raw"},{"term_id":28101,"name":"GPS","slug":"gps","term_group":0,"term_taxonomy_id":28101,"taxonomy":"post_tag","description":"","parent":0,"count":38,"filter":"raw"},{"term_id":24341,"name":"python","slug":"python","term_group":0,"term_taxonomy_id":24341,"taxonomy":"post_tag","description":"","parent":0,"count":171,"filter":"raw"}],"category_data":[{"term_id":23341,"name":"Analytics","slug":"analytics","term_group":0,"term_taxonomy_id":23341,"taxonomy":"category","description":"","parent":0,"count":1326,"filter":"raw"},{"term_id":23851,"name":"Data Management","slug":"data-management","term_group":0,"term_taxonomy_id":23851,"taxonomy":"category","description":"","parent":0,"count":920,"filter":"raw"}],"product_data":[{"term_id":36991,"name":"ArcMap","slug":"arcgis-desktop","term_group":0,"term_taxonomy_id":36991,"taxonomy":"product","description":"","parent":36981,"count":325,"filter":"raw"}],"primary_product_link":"https:\/\/www.esri.com\/arcgis-blog\/?s=#&products=arcgis-desktop","_links":{"self":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/168331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/users\/4031"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/comments?post=168331"}],"version-history":[{"count":0,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/168331\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/media?parent=168331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/categories?post=168331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/tags?post=168331"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/industry?post=168331"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/product?post=168331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}