{"id":305196,"date":"2021-09-12T11:21:32","date_gmt":"2021-09-12T11:21:32","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=305196"},"modified":"2024-07-24T12:45:54","modified_gmt":"2024-07-24T12:45:54","slug":"generate-xml-file-in-magento-2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/","title":{"rendered":"Generate XML file in Magento 2"},"content":{"rendered":"\n<p>In this blog, we are going to learn that how we can generate XML files or how we can write data in xml file.<\/p>\n\n\n\n<p>In Magento 2, it provides <strong> \\Magento\\Framework\\Convert\\ConvertArray <\/strong>class that contains the <strong>assocToXml<\/strong> method to convert an array into XML format. This formatted data we can write in the XML file.<\/p>\n\n\n\n<p>In the following example, we have created an array that will be written in the XML file<\/p>\n\n\n\n<p>Here, we have created GenerateXml.php Controller file inside app\/code\/Vendor\/CustomModule\/Controller\/Demo\/ directory.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Vendor_CustomModule\n * @author    Webkul\n * @copyright Copyright (c) Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\nnamespace Vendor\\CustomModule\\Controller\\Demo;\n\nuse Magento\\Framework\\App\\Action\\Action;\nuse Magento\\Framework\\App\\Action\\Context;\n\nclass GenerateXml extends Action\n{\n    \/**\n     * @var \\Magento\\Framework\\Filesystem\\Io\\File\n     *\/\n    protected $file;\n\n    \/**\n     * @var \\Magento\\Framework\\Convert\\ConvertArray\n     *\/\n    protected $convertArray;\n    \n    \/**\n     * @var \\Magento\\Framework\\Controller\\Result\\JsonFactory\n     *\/\n    protected $resultJsonFactory;\n\n    \/**\n     * initialization\n     *\n     * @param Context $context\n     * @param \\Magento\\Framework\\Filesystem\\Io\\File $file\n     * @param \\Magento\\Framework\\Convert\\ConvertArray $convertArray\n     * @param \\Magento\\Framework\\Controller\\Result\\JsonFactory $resultJsonFactory\n     *\/\n    public function __construct(\n        Context $context,\n        \\Magento\\Framework\\Filesystem\\Io\\File $file,\n        \\Magento\\Framework\\Convert\\ConvertArray $convertArray,\n        \\Magento\\Framework\\Controller\\Result\\JsonFactory $resultJsonFactory\n    ) {\n        $this-&gt;file         = $file;\n        $this-&gt;convertArray = $convertArray;\n        $this-&gt;resultJsonFactory = $resultJsonFactory;\n        parent::__construct($context);\n    }\n\n    \/**\n     * Execute\n     * @return json\n     *\/\n    public function execute()\n    {\n        $result = $this-&gt;resultJsonFactory-&gt;create();\n        $flag   = $this-&gt;generateXml(); \/\/call method to generate xml file\n        $data   = &#091;&#039;message&#039; =&gt; &#039;&#039;, &#039;success&#039; =&gt; false];\n        if ($flag) {\n            $data   = &#091;&#039;message&#039; =&gt; &#039;File products.xml created.&#039;, &#039;success&#039; =&gt; true];\n        } else {\n            $data   = &#091;&#039;message&#039; =&gt; &#039;Something went wrong.&#039;, &#039;success&#039; =&gt; false];\n        }\n        return $result-&gt;setData($data);\n    }\n\n    \/**\n     * Generate xml file\n     * @return bool\n     *\/\n    public function generateXml()\n    {\n        $result = false;\n        try {\n            $product1 = &#091;\n                &quot;productId&quot; =&gt; 1,\n                &quot;productName&quot; =&gt; &quot;T-Shirt&quot;,\n                &quot;sku&quot; =&gt; &quot;tshirt&quot;,\n                &quot;price&quot; =&gt; 45,\n                &quot;baseCurrency&quot; =&gt; &quot;USD&quot;,\n                &quot;customAttributes&quot; =&gt; &#091;\n                    &quot;color&quot; =&gt; &quot;Red&quot;,\n                    &quot;printType&quot; =&gt; &quot;Floral&quot;,\n                    &quot;sellerInfo&quot; =&gt; &#091;\n                        &quot;sellerName&quot; =&gt; &quot;Saroz&quot;,\n                        &quot;contact&quot; =&gt; 987678\n                    ]\n                ]\n            ];\n            $product2 = &#091;\n                &quot;productId&quot; =&gt; 2,\n                &quot;productName&quot; =&gt; &quot;Women T-Shirt&quot;,\n                &quot;sku&quot; =&gt; &quot;w-tshirt&quot;,\n                &quot;price&quot; =&gt; 55,\n                &quot;baseCurrency&quot; =&gt; &quot;EUR&quot;,\n                &quot;customAttributes&quot; =&gt; &#091;\n                    &quot;color&quot; =&gt; &quot;Green&quot;,\n                    &quot;printType&quot; =&gt; &quot;Plain&quot;,\n                    &quot;sellerInfo&quot; =&gt; &#091;\n                        &quot;sellerName&quot; =&gt; &quot;Reema&quot;,\n                        &quot;contact&quot; =&gt; 898912\n                    ]\n                ]\n            ];\n            $products = &#091;\n               &quot;productList1&quot; =&gt; &#091;\n                  &quot;product1&quot;=&gt;$product1,\n                  &quot;product2&quot;=&gt;$product2\n               ]\n            ];\n            \n            \/\/ ConvertArray function assocToXml to create xmlContents\n            $xmlContents = $this-&gt;convertArray-&gt;assocToXml($products, &quot;productLists&quot;);\n    \n            \/\/ convert it to xml using asXML() function\n            $content = $xmlContents-&gt;asXML();\n            \n            $this-&gt;file-&gt;write(&quot;products.xml&quot;, $content);\n            $result = true;\n        } catch(\\Exception $e) {\n            $result = false;\n        }\n        return $result;\n    }\n}<\/pre>\n\n\n\n<p>When we execute the above controller in the browser&#8217;s window, we get the following response, and an XML file generate named as products.xml inside &lt;magento-root-dir&gt;\/pub\/ directory.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1116\" height=\"140\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/generatexmlControllerResponse.png\" alt=\"generatexmlControllerResponse\" class=\"wp-image-305197\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/generatexmlControllerResponse.png 1116w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/generatexmlControllerResponse-300x38.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/generatexmlControllerResponse-250x31.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/generatexmlControllerResponse-768x96.png 768w\" sizes=\"(max-width: 1116px) 100vw, 1116px\" loading=\"lazy\" \/><figcaption class=\"wp-element-caption\">GenerateXml Controller&#8217;s Response<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"839\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/productsDotXmlFileResponse-1200x839.png\" alt=\"productsDotXmlFileResponse\" class=\"wp-image-305198\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/productsDotXmlFileResponse-1200x839.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/productsDotXmlFileResponse-300x210.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/productsDotXmlFileResponse-250x175.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/productsDotXmlFileResponse-768x537.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/productsDotXmlFileResponse.png 1259w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><figcaption class=\"wp-element-caption\">array data in XML format in products.xml file<\/figcaption><\/figure>\n\n\n\n<p><strong>Note: <\/strong>Don&#8217;t pass any value in a simple array format like [&#8220;XL&#8221;, &#8220;XS&#8221;] in any key. It should be like [&#8220;size1&#8243;=>&#8221;XL&#8221;, &#8220;size2&#8243;=>&#8221;XS&#8221;] associative array. Because when you will use simple array like [&#8220;XL&#8221;, &#8220;XS&#8221;] format, then generated XML will not be valid.<\/p>\n\n\n\n<p>Please refer to the following example for a better understanding.<\/p>\n\n\n\n<p><strong>Example: <\/strong>Array $product contains a simple array in the &#8220;size&#8221; key. Its generated XML will be in the following XML format. But when you will open this XML in the browser&#8217;s window, it will show an error like the following image.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">$products = &#091;\n                &quot;productId&quot; =&gt; 1,\n                &quot;productName&quot; =&gt; &quot;T-Shirt&quot;,\n                &quot;sku&quot; =&gt; &quot;tshirt&quot;,\n                &quot;price&quot; =&gt; 45,\n                &quot;baseCurrency&quot; =&gt; &quot;USD&quot;,\n                &quot;customAttributes&quot; =&gt; &#091;\n                    &quot;color&quot; =&gt; &quot;Red&quot;,\n                    &quot;size&quot; =&gt; &#091;&quot;XL&quot;, &quot;XS&quot;]\n                ]\n            ];\n            \/\/ ConvertArray function assocToXml to create xmlContents\n            $xmlContents = $this-&gt;convertArray-&gt;assocToXml($products, &quot;productLists&quot;);\n    \n            \/\/ convert it to xml using asXML() function\n            $content = $xmlContents-&gt;asXML();\n            \n            $this-&gt;file-&gt;write(&quot;products.xml&quot;, $content);<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;\n&lt;productLists&gt;\n    &lt;productId&gt;1&lt;\/productId&gt;\n    &lt;productName&gt;T-Shirt&lt;\/productName&gt;\n    &lt;sku&gt;tshirt&lt;\/sku&gt;\n    &lt;price&gt;45&lt;\/price&gt;\n    &lt;baseCurrency&gt;USD&lt;\/baseCurrency&gt;\n    &lt;customAttributes&gt;\n        &lt;color&gt;Red&lt;\/color&gt;\n        &lt;size&gt;\n            &lt;0&gt;XL&lt;\/0&gt;\n            &lt;1&gt;XS&lt;\/1&gt;\n        &lt;\/size&gt;\n    &lt;\/customAttributes&gt;\n&lt;\/productLists&gt;<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"258\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/incorrectXmlFormat-1200x258.png\" alt=\"incorrectXmlFormat\" class=\"wp-image-305201\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/incorrectXmlFormat-1200x258.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/incorrectXmlFormat-300x65.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/incorrectXmlFormat-250x54.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/incorrectXmlFormat-768x165.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/incorrectXmlFormat-1536x331.png 1536w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/incorrectXmlFormat.png 1686w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><figcaption class=\"wp-element-caption\">Error when the key name is integer type like 0, 1, etc.<\/figcaption><\/figure>\n\n\n\n<p>Hope this will be helpful. Thanks \ud83d\ude42<br><br>Next Blog: <a href=\"https:\/\/webkul.com\/blog\/read-xml-data-from-a-xml-file-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">Read XML Data from a XML file in Magento 2<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, we are going to learn that how we can generate XML files or how we can write data in xml file. In Magento 2, it provides \\Magento\\Framework\\Convert\\ConvertArray class that contains the assocToXml method to convert an array into XML format. This formatted data we can write in the XML file. In the <a href=\"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":249,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9121],"tags":[12032,2070,12031,12030,255],"class_list":["post-305196","post","type-post","status-publish","format-standard","hentry","category-magento-2","tag-generate-xml-file","tag-magento2","tag-read-xml","tag-write-xml","tag-xml"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Generate XML file in Magento 2 - Webkul Blog<\/title>\n<meta name=\"description\" content=\"Generate XML file in Magento 2, how to generate XML file in Magento 2, easiest way to generate XMl in Magento 2\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Generate XML file in Magento 2 - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Generate XML file in Magento 2, how to generate XML file in Magento 2, easiest way to generate XMl in Magento 2\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-09-12T11:21:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-24T12:45:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/09\/generatexmlControllerResponse.png\" \/>\n<meta name=\"author\" content=\"Khushboo Sahu\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Khushboo Sahu\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/\"},\"author\":{\"name\":\"Khushboo Sahu\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/f94b8f53397bf85810761d76c98fadca\"},\"headline\":\"Generate XML file in Magento 2\",\"datePublished\":\"2021-09-12T11:21:32+00:00\",\"dateModified\":\"2024-07-24T12:45:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/\"},\"wordCount\":258,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/09\/generatexmlControllerResponse.png\",\"keywords\":[\"Generate XML File\",\"Magento2\",\"Read XML\",\"Write XML\",\"xml\"],\"articleSection\":[\"Magento 2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/\",\"url\":\"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/\",\"name\":\"Generate XML file in Magento 2 - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/09\/generatexmlControllerResponse.png\",\"datePublished\":\"2021-09-12T11:21:32+00:00\",\"dateModified\":\"2024-07-24T12:45:54+00:00\",\"description\":\"Generate XML file in Magento 2, how to generate XML file in Magento 2, easiest way to generate XMl in Magento 2\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/generatexmlControllerResponse.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/generatexmlControllerResponse.png\",\"width\":1116,\"height\":140,\"caption\":\"generatexmlControllerResponse\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Generate XML file in Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/f94b8f53397bf85810761d76c98fadca\",\"name\":\"Khushboo Sahu\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cabac965df656d114e6bf340df07518c990eda03bb09265dbd5c17f1097adaae?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cabac965df656d114e6bf340df07518c990eda03bb09265dbd5c17f1097adaae?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"caption\":\"Khushboo Sahu\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/khushboo-sahu062\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Generate XML file in Magento 2 - Webkul Blog","description":"Generate XML file in Magento 2, how to generate XML file in Magento 2, easiest way to generate XMl in Magento 2","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:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/","og_locale":"en_US","og_type":"article","og_title":"Generate XML file in Magento 2 - Webkul Blog","og_description":"Generate XML file in Magento 2, how to generate XML file in Magento 2, easiest way to generate XMl in Magento 2","og_url":"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2021-09-12T11:21:32+00:00","article_modified_time":"2024-07-24T12:45:54+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/09\/generatexmlControllerResponse.png","type":"","width":"","height":""}],"author":"Khushboo Sahu","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Khushboo Sahu","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/"},"author":{"name":"Khushboo Sahu","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/f94b8f53397bf85810761d76c98fadca"},"headline":"Generate XML file in Magento 2","datePublished":"2021-09-12T11:21:32+00:00","dateModified":"2024-07-24T12:45:54+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/"},"wordCount":258,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/09\/generatexmlControllerResponse.png","keywords":["Generate XML File","Magento2","Read XML","Write XML","xml"],"articleSection":["Magento 2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/","url":"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/","name":"Generate XML file in Magento 2 - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/09\/generatexmlControllerResponse.png","datePublished":"2021-09-12T11:21:32+00:00","dateModified":"2024-07-24T12:45:54+00:00","description":"Generate XML file in Magento 2, how to generate XML file in Magento 2, easiest way to generate XMl in Magento 2","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/generatexmlControllerResponse.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/09\/generatexmlControllerResponse.png","width":1116,"height":140,"caption":"generatexmlControllerResponse"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/generate-xml-file-in-magento-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Generate XML file in Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/f94b8f53397bf85810761d76c98fadca","name":"Khushboo Sahu","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cabac965df656d114e6bf340df07518c990eda03bb09265dbd5c17f1097adaae?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cabac965df656d114e6bf340df07518c990eda03bb09265dbd5c17f1097adaae?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","caption":"Khushboo Sahu"},"url":"https:\/\/webkul.com\/blog\/author\/khushboo-sahu062\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/305196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/249"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=305196"}],"version-history":[{"count":6,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/305196\/revisions"}],"predecessor-version":[{"id":454549,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/305196\/revisions\/454549"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=305196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=305196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=305196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}