{"id":2986,"date":"2018-11-27T15:22:19","date_gmt":"2018-11-27T09:52:19","guid":{"rendered":"https:\/\/blog.pheonixsolutions.com\/?p=2986"},"modified":"2018-11-27T15:22:19","modified_gmt":"2018-11-27T09:52:19","slug":"convert-xml-to-json-format-and-store-in-db-using-python","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/","title":{"rendered":"Convert  xml to Json  format and store in DB using Python"},"content":{"rendered":"<h2>Convert XML to Json format and store in Database using Python<\/h2>\n<h3><strong>Date posted:23 \/11 \/ 2018<\/strong><\/h3>\n<h2>Introduction:<\/h2>\n<p>In this article, it is applicable to convert only a very small Xml file format\u00a0 in to Json\u00a0 format. The converted Json format will be inserted in to a\u00a0 existing database in Mysql.\u00a0 This example is explained based on Linux environment in Centos 7.<\/p>\n<h2>Prerequisites:<\/h2>\n<ul>\n<li>For <strong>centOS<\/strong> and <strong>RHEL\u00a0<\/strong> based environment:\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"># sudo yum install python<\/pre>\n<\/li>\n<li><strong>Pip installation<\/strong>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"># curl -O https:\/\/bootstrap.pypa.io\/get-pip.py<\/pre>\n<p>And\u00a0 then execute,<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#python get-pip.py<\/pre>\n<p>confirm the installed PIP version,<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"># pip \u2013version<\/pre>\n<\/li>\n<\/ul>\n<h2><strong>Importing Modules and their Pip Installation:<\/strong><\/h2>\n<p>While Importing, if the packaging Modules of\u00a0 any one among the above missed, will arise\u00a0<strong>\u00a0Import error.<\/strong> To eradicate the error follow these step by step modules to import\u00a0 using pip Installation.<\/p>\n<p>1. Importing Mysqldb:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Yum install MYSQL-python<\/pre>\n<p><a href=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/blog-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2989\" src=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/blog-4.png\" alt=\"\" width=\"470\" height=\"178\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/blog-4.png 470w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/blog-4-300x114.png 300w\" sizes=\"auto, (max-width: 470px) 100vw, 470px\" \/><\/a><\/p>\n<p>2. Importing mysql.connector:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">pip install mysql-connector-python<\/pre>\n<p><a href=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/Blog1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2991\" src=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/Blog1.png\" alt=\"\" width=\"796\" height=\"169\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/Blog1.png 796w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/Blog1-300x64.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/Blog1-768x163.png 768w\" sizes=\"auto, (max-width: 796px) 100vw, 796px\" \/><\/a><\/p>\n<p>3.Importing\u00a0 xmltodict:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">pip install xmltodict<\/pre>\n<p><a href=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/blog3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2993\" src=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/blog3.png\" alt=\"\" width=\"833\" height=\"118\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/blog3.png 833w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/blog3-300x42.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/blog3-768x109.png 768w\" sizes=\"auto, (max-width: 833px) 100vw, 833px\" \/><\/a><\/p>\n<p>4.Importing Json:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">pip install xmljson<\/pre>\n<p><a href=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/blog2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2992\" src=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/blog2.png\" alt=\"\" width=\"792\" height=\"121\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/blog2.png 792w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/blog2-300x46.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/blog2-768x117.png 768w\" sizes=\"auto, (max-width: 792px) 100vw, 792px\" \/><\/a><\/p>\n<h2><strong>Executing\u00a0 script:<\/strong><\/h2>\n<p><strong>NOTE:\u00a0<\/strong>This script is executed only for small XML format convert in to JSON\u00a0 format and\u00a0 to\u00a0 store\u00a0 in\u00a0 a table row of\u00a0 <strong>MySQL DB.<\/strong><\/p>\n<p>The<strong> Key\u00a0 role\u00a0<\/strong> must be followed before\u00a0 proceeding\u00a0 this\u00a0 script are as follows.<\/p>\n<ul>\n<li>Enter\u00a0 \u00a0your\u00a0 appropriate mysql username and password\u00a0 in the script .Please replace with the below script\u00a0 instead of &#8220;<strong>usernamexxx<\/strong>&#8221; and &#8220;<strong>passxxx<\/strong>&#8220;.<\/li>\n<li>create a database Name\u00a0 of your choice\u00a0 and replace in the below script instead of\u00a0 &#8220;<strong>DBname created<\/strong>&#8220;<\/li>\n<\/ul>\n<p><strong>\u00a0 NOTE<\/strong>:\u00a0 Database must be already created and appropriate DB name should given in script.<\/p>\n<ul>\n<li>\u00a0BY the execution of\u00a0 script Table will automatically generated in Mysql . The table name called <strong>Jsonobject\u00a0<\/strong> and having two column named <strong>id<\/strong> and<strong> Json.<\/strong><\/li>\n<li>All converted Json format\u00a0 will store in first row of Json.<\/li>\n<li>If xml file is Big, it won&#8217;t fix in the first Json row of DB and it will result in error.<\/li>\n<li>Create a\u00a0 file name called<strong>\u00a0 xmltoJson.py<\/strong> and execute the script with your convenience.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import MySQLdb\r\nimport mysql.connector\r\nimport xmltodict\r\nimport pprint\r\nimport json\r\nimport sys\r\n\r\ntry:\r\nmy_xml= sys.argv[1]\r\nexcept:\r\nprint(\"Help : please enter your valid xml file\")\r\nif len(sys.argv) &lt; 2:\r\nprint 'You failed to provide your valid xml file'\r\nsys.exit(1)\r\n\r\nwith open(my_xml) as fd:\r\ndoc = xmltodict.parse(fd.read())\r\n\r\npp = pprint.PrettyPrinter(indent=1000)\r\npp.pprint(json.dumps(doc))\r\n\r\nmydb = MySQLdb.connect(\"localhost\",\"usernamexxx\",\"Passxxx\",\"DBname created\" )\r\n\r\nprint(mydb)\r\nmycursor = mydb.cursor()\r\n\r\nmycursor.execute(\"SHOW DATABASES\")\r\nfor x in mycursor:\r\n\r\nmycursor.execute(\"SHOW DATABASES\")\r\nfor x in mycursor:\r\nprint(x)\r\ntry:\r\nmycursor.execute(\"CREATE TABLE Jsonobject (id VARCHAR(255), Json VARCHAR(255))\")\r\nexcept:\r\nprint(\"Table created successfully. Inserting jason objects ...\")\r\ninsert = \"INSERT INTO Jsonobject (id) VALUES (%d)\"\r\ninsert = \"INSERT INTO Jsonobject (Json) VALUES (%s)\"\r\nmycursor.execute(insert, (json.dumps(doc),))\r\nprint(mycursor.rowcount, \"record inserted.\")\r\nmydb.commit()\r\n<\/pre>\n<h2><strong>Output Execution and result:<\/strong><\/h2>\n<p>Sample xml file is taken and saved as\u00a0 <strong>examples.xml.\u00a0<\/strong>I have attached my xml file below.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;mec&gt;\r\n&lt;student&gt;\r\n&lt;firstname&gt;James&lt;\/firstname&gt;\r\n&lt;lastname&gt;Smith&lt;\/lastname&gt;\r\n&lt;\/student&gt;\r\n&lt;\/mec&gt;\r\n\r\n<\/pre>\n<p>Let us see how the xml to json\u00a0 occurs.<\/p>\n<p><a href=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/Json-execution.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3014\" src=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/Json-execution.png\" alt=\"\" width=\"967\" height=\"99\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/Json-execution.png 967w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/Json-execution-300x31.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/Json-execution-768x79.png 768w\" sizes=\"auto, (max-width: 967px) 100vw, 967px\" \/><\/a><\/p>\n<p>The code is scripted in a manner, one xml file executed at once.During execution follow this below example.<\/p>\n<p>Python\u00a0<strong> programfile.py<\/strong>\u00a0 <strong>xmlfile<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Python  xmltojson.py examples.xml<\/pre>\n<p><strong>1.Converted Json format:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">'{\"mec\": {\"student\": {\"firstname\": \"James\", \"lastname\": \"Smith\"}}}'\r\n<\/pre>\n<p><strong>2.Inserting conformation:<\/strong><\/p>\n<p><a href=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/inserting.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3015\" src=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/inserting.png\" alt=\"\" width=\"664\" height=\"50\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/inserting.png 664w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/inserting-300x23.png 300w\" sizes=\"auto, (max-width: 664px) 100vw, 664px\" \/><\/a><\/p>\n<p><strong>3.Output in Mysql DB:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Use DBname;<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">select * from Jsonobject;<\/pre>\n<p><strong>4.The expected output is acheived.<\/strong><\/p>\n<p><a href=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/Json-result.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3016\" src=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/Json-result.png\" alt=\"\" width=\"955\" height=\"114\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/Json-result.png 955w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/Json-result-300x36.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/Json-result-768x92.png 768w\" sizes=\"auto, (max-width: 955px) 100vw, 955px\" \/><\/a><\/p>\n<p>That&#8217;s it! Hope it&#8217;s useful. Please leave us the comment for any queries.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Convert XML to Json format and store in Database using Python Date posted:23 \/11 \/ 2018 Introduction: In this article, it is applicable to convert only a very small Xml file format\u00a0 in to Json\u00a0 format. The converted Json format will be inserted in to a\u00a0 existing database in Mysql.\u00a0&hellip; <a href=\"https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/\" class=\"more-link read-more\" rel=\"bookmark\">Continue Reading <span class=\"screen-reader-text\">Convert  xml to Json  format and store in DB using Python<\/span><i class=\"fa fa-arrow-right\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[259,290],"tags":[500,498,499],"class_list":{"0":"post-2986","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-python","7":"category-script","8":"tag-python-db-creation","9":"tag-python-mysql-access","10":"tag-python-xml-to-json","11":"h-entry","13":"h-as-article"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Pheonix Solutions - We Empower Your Business Growth<\/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:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pheonix Solutions - We Empower Your Business Growth\" \/>\n<meta property=\"og:description\" content=\"Convert XML to Json format and store in Database using Python Date posted:23 \/11 \/ 2018 Introduction: In this article, it is applicable to convert only a very small Xml file format\u00a0 in to Json\u00a0 format. The converted Json format will be inserted in to a\u00a0 existing database in Mysql.\u00a0&hellip; Continue Reading Convert xml to Json format and store in DB using Python\" \/>\n<meta property=\"og:url\" content=\"https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/\" \/>\n<meta property=\"og:site_name\" content=\"PHEONIXSOLUTIONS\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/PheonixSolutions-209942982759387\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-11-27T09:52:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/blog-4.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pheonixsolution\" \/>\n<meta name=\"twitter:site\" content=\"@pheonixsolution\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/convert-xml-to-json-format-and-store-in-db-using-python\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/convert-xml-to-json-format-and-store-in-db-using-python\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/0ffa33d73c869faec2d50e79c24e3503\"},\"headline\":\"Convert xml to Json format and store in DB using Python\",\"datePublished\":\"2018-11-27T09:52:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/convert-xml-to-json-format-and-store-in-db-using-python\\\/\"},\"wordCount\":379,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/convert-xml-to-json-format-and-store-in-db-using-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blog.pheonixsolutions.com\\\/wp-content\\\/uploads\\\/2018\\\/11\\\/blog-4.png\",\"keywords\":[\"python DB creation\",\"python mysql access\",\"python xml to json\"],\"articleSection\":[\"Python\",\"Script\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/convert-xml-to-json-format-and-store-in-db-using-python\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/convert-xml-to-json-format-and-store-in-db-using-python\\\/\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/convert-xml-to-json-format-and-store-in-db-using-python\\\/\",\"name\":\"Pheonix Solutions - We Empower Your Business Growth\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/convert-xml-to-json-format-and-store-in-db-using-python\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/convert-xml-to-json-format-and-store-in-db-using-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blog.pheonixsolutions.com\\\/wp-content\\\/uploads\\\/2018\\\/11\\\/blog-4.png\",\"datePublished\":\"2018-11-27T09:52:19+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/convert-xml-to-json-format-and-store-in-db-using-python\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/convert-xml-to-json-format-and-store-in-db-using-python\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/convert-xml-to-json-format-and-store-in-db-using-python\\\/#primaryimage\",\"url\":\"https:\\\/\\\/blog.pheonixsolutions.com\\\/wp-content\\\/uploads\\\/2018\\\/11\\\/blog-4.png\",\"contentUrl\":\"https:\\\/\\\/blog.pheonixsolutions.com\\\/wp-content\\\/uploads\\\/2018\\\/11\\\/blog-4.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/convert-xml-to-json-format-and-store-in-db-using-python\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Convert xml to Json format and store in DB using Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/\",\"name\":\"Pheonix Solutions\",\"description\":\"We Empower Your Business Growth\",\"publisher\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#organization\",\"name\":\"PheonixSolutions\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/12\\\/logo.png\",\"contentUrl\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/12\\\/logo.png\",\"width\":454,\"height\":300,\"caption\":\"PheonixSolutions\"},\"image\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/PheonixSolutions-209942982759387\\\/\",\"https:\\\/\\\/x.com\\\/pheonixsolution\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/0ffa33d73c869faec2d50e79c24e3503\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"http:\\\/\\\/blog.pheonixsolutions.com\"],\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pheonix Solutions - We Empower Your Business Growth","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:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/","og_locale":"en_US","og_type":"article","og_title":"Pheonix Solutions - We Empower Your Business Growth","og_description":"Convert XML to Json format and store in Database using Python Date posted:23 \/11 \/ 2018 Introduction: In this article, it is applicable to convert only a very small Xml file format\u00a0 in to Json\u00a0 format. The converted Json format will be inserted in to a\u00a0 existing database in Mysql.\u00a0&hellip; Continue Reading Convert xml to Json format and store in DB using Python","og_url":"https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/","og_site_name":"PHEONIXSOLUTIONS","article_publisher":"https:\/\/www.facebook.com\/PheonixSolutions-209942982759387\/","article_published_time":"2018-11-27T09:52:19+00:00","og_image":[{"url":"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/blog-4.png","type":"","width":"","height":""}],"author":"admin","twitter_card":"summary_large_image","twitter_creator":"@pheonixsolution","twitter_site":"@pheonixsolution","twitter_misc":{"Written by":"admin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/#article","isPartOf":{"@id":"https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/"},"author":{"name":"admin","@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/person\/0ffa33d73c869faec2d50e79c24e3503"},"headline":"Convert xml to Json format and store in DB using Python","datePublished":"2018-11-27T09:52:19+00:00","mainEntityOfPage":{"@id":"https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/"},"wordCount":379,"commentCount":0,"publisher":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#organization"},"image":{"@id":"https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/blog-4.png","keywords":["python DB creation","python mysql access","python xml to json"],"articleSection":["Python","Script"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/","url":"https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/","name":"Pheonix Solutions - We Empower Your Business Growth","isPartOf":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/#primaryimage"},"image":{"@id":"https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/blog-4.png","datePublished":"2018-11-27T09:52:19+00:00","breadcrumb":{"@id":"https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/#primaryimage","url":"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/blog-4.png","contentUrl":"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2018\/11\/blog-4.png"},{"@type":"BreadcrumbList","@id":"https:\/\/pheonixsolutions.com\/blog\/convert-xml-to-json-format-and-store-in-db-using-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/pheonixsolutions.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Convert xml to Json format and store in DB using Python"}]},{"@type":"WebSite","@id":"https:\/\/pheonixsolutions.com\/blog\/#website","url":"https:\/\/pheonixsolutions.com\/blog\/","name":"Pheonix Solutions","description":"We Empower Your Business Growth","publisher":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/pheonixsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/pheonixsolutions.com\/blog\/#organization","name":"PheonixSolutions","url":"https:\/\/pheonixsolutions.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2016\/12\/logo.png","contentUrl":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2016\/12\/logo.png","width":454,"height":300,"caption":"PheonixSolutions"},"image":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/PheonixSolutions-209942982759387\/","https:\/\/x.com\/pheonixsolution"]},{"@type":"Person","@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/person\/0ffa33d73c869faec2d50e79c24e3503","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g","caption":"admin"},"sameAs":["http:\/\/blog.pheonixsolutions.com"],"url":"https:\/\/pheonixsolutions.com\/blog\/author\/admin\/"}]}},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p7F4uM-Ma","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2986","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=2986"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2986\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}