{"id":525,"date":"2024-08-10T19:09:46","date_gmt":"2024-08-10T17:09:46","guid":{"rendered":"https:\/\/honadi.com\/outils\/?page_id=525"},"modified":"2024-09-27T17:28:17","modified_gmt":"2024-09-27T15:28:17","slug":"xmlviewer","status":"publish","type":"page","link":"https:\/\/honadi.com\/outils\/xmlviewer\/","title":{"rendered":"XMLViewer"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"525\" class=\"elementor elementor-525\" data-elementor-post-type=\"page\">\n\t\t\t\t<div class=\"elementor-element elementor-element-6224ec9 e-flex e-con-boxed wpr-particle-no wpr-jarallax-no wpr-parallax-no wpr-sticky-section-no wpr-equal-height-no e-con e-parent\" data-id=\"6224ec9\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-485601d elementor-widget elementor-widget-html\" data-id=\"485601d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"xml-formatter-container\">\n    <input type=\"file\" id=\"fileInput\" accept=\".xml\">\n    <textarea id=\"xmlContent\" placeholder=\"Collez votre XML ici ou t\u00e9l\u00e9chargez un fichier\"><\/textarea>\n    <button onclick=\"formatXML()\">Formater XML<\/button>\n    <button onclick=\"downloadXML()\">T\u00e9l\u00e9charger XML<\/button>\n    <div id=\"error\"><\/div>\n<\/div>\n\n<style>\n    .xml-formatter-container {\n        font-family: Arial, sans-serif;\n        line-height: 1.6;\n        color: #030E41;\n        padding: 20px;\n        max-width: 800px;\n        margin: 0 auto;\n    }\n    .xml-formatter-container textarea {\n        width: 100%;\n        height: 300px;\n        margin-bottom: 10px;\n        border: 1px solid #A0616A;\n        padding: 10px;\n        font-family: monospace;\n    }\n    .xml-formatter-container button {\n        background-color: #F9B200;\n        color: #FFFFFF;\n        border: none;\n        padding: 10px 20px;\n        cursor: pointer;\n        margin-right: 10px;\n    }\n    .xml-formatter-container button:hover {\n        background-color: #A0616A;\n    }\n    .xml-formatter-container #error {\n        color: red;\n        margin-top: 10px;\n    }\n<\/style>\n\n<script>\nfunction formatXML() {\n    const xmlContent = document.getElementById('xmlContent').value;\n    if (!xmlContent) {\n        showError(\"Aucun contenu XML fourni.\");\n        return;\n    }\n\n    try {\n        const parser = new DOMParser();\n        const xmlDoc = parser.parseFromString(xmlContent, \"text\/xml\");\n        \n        if (xmlDoc.getElementsByTagName(\"parsererror\").length > 0) {\n            throw new Error(\"XML invalide\");\n        }\n\n        const serializer = new XMLSerializer();\n        let formatted = serializer.serializeToString(xmlDoc);\n        formatted = formatted.replace(\/>\/g, \">\\n\").replace(\/\\t\/g, \"  \");\n        formatted = formatted.replace(\/\\n{2,}\/g, \"\\n\");\n\n        document.getElementById('xmlContent').value = formatted;\n        showError(\"\");\n    } catch (error) {\n        showError(\"Erreur lors du formatage XML : \" + error.message);\n    }\n}\n\nfunction downloadXML() {\n    const xmlContent = document.getElementById('xmlContent').value;\n    if (!xmlContent) {\n        showError(\"Aucun contenu XML \u00e0 t\u00e9l\u00e9charger.\");\n        return;\n    }\n\n    try {\n        const parser = new DOMParser();\n        const xmlDoc = parser.parseFromString(xmlContent, \"text\/xml\");\n        \n        if (xmlDoc.getElementsByTagName(\"parsererror\").length > 0) {\n            throw new Error(\"XML invalide\");\n        }\n\n        const blob = new Blob([xmlContent], { type: 'text\/xml' });\n        const url = URL.createObjectURL(blob);\n        const a = document.createElement('a');\n        a.href = url;\n        a.download = 'formatted.xml';\n        document.body.appendChild(a);\n        a.click();\n        document.body.removeChild(a);\n        URL.revokeObjectURL(url);\n        showError(\"\");\n    } catch (error) {\n        showError(\"Erreur lors du t\u00e9l\u00e9chargement : \" + error.message);\n    }\n}\n\nfunction showError(message) {\n    document.getElementById('error').textContent = message;\n}\n\ndocument.addEventListener('DOMContentLoaded', function() {\n    document.getElementById('fileInput').addEventListener('change', function(event) {\n        const file = event.target.files[0];\n        if (file) {\n            const reader = new FileReader();\n            reader.onload = function(e) {\n                document.getElementById('xmlContent').value = e.target.result;\n            };\n            reader.onerror = function(e) {\n                showError(\"Erreur lors de la lecture du fichier : \" + e.target.error);\n            };\n            reader.readAsText(file);\n        }\n    });\n});\n<\/script>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Formater XML T\u00e9l\u00e9charger XML<\/p>\n","protected":false},"author":1,"featured_media":3009,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"no-sidebar","site-content-layout":"","ast-site-content-layout":"full-width-container","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"disabled","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"class_list":["post-525","page","type-page","status-publish","has-post-thumbnail","hentry"],"_links":{"self":[{"href":"https:\/\/honadi.com\/outils\/wp-json\/wp\/v2\/pages\/525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/honadi.com\/outils\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/honadi.com\/outils\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/honadi.com\/outils\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/honadi.com\/outils\/wp-json\/wp\/v2\/comments?post=525"}],"version-history":[{"count":7,"href":"https:\/\/honadi.com\/outils\/wp-json\/wp\/v2\/pages\/525\/revisions"}],"predecessor-version":[{"id":535,"href":"https:\/\/honadi.com\/outils\/wp-json\/wp\/v2\/pages\/525\/revisions\/535"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/honadi.com\/outils\/wp-json\/wp\/v2\/media\/3009"}],"wp:attachment":[{"href":"https:\/\/honadi.com\/outils\/wp-json\/wp\/v2\/media?parent=525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}