Subscribe for notification
Software Tools

JSON to XML converter

NathTech’s Tools ,

JSON to XML converter  :

This is a responsive JSON to XML converter tool. You can input JSON data, and it will convert it to XML format when you click the “Convert” button. The styling is done using CSS, and Font Awesome library is used for the conversion icon.

 

 

 

JSON to XML Converter


function buildXml(obj, nodeName) { let xmlString = '';

if (Array.isArray(obj)) { for (let item of obj) { xmlString += `<${nodeName}>${buildXml(item, nodeName.slice(0, -1))}${nodeName}>`; } } else if (typeof obj === 'object') { for (let key in obj) { xmlString += buildXml(obj[key], key); } } else { xmlString += obj; }

return xmlString; }

xml += `<${rootName}>`; xml += buildXml(obj, rootName); xml += `${rootName}>`;

return xml; }

function convert() { const jsonInput = document.getElementById('jsonInput').value.trim();

try { const jsonObject = JSON.parse(jsonInput); const xmlOutput = jsonToXml(jsonObject); document.getElementById('output').innerHTML = `

${xmlOutput}

`; } catch (error) { document.getElementById('output').innerHTML = `

Invalid JSON format. Please enter valid JSON.

`; } }

 

shmbhnthjh8

Music composer, blogger,website creator,freelancer

Recent Posts

Toncoin: Everything You Need to Know About the Future of this Unique Cryptocurrency

NathTech Guid,   Introduction to Toncoin (TON) Toncoin (TON) is the native cryptocurrency of The…

2 months ago

How to Get Naturally Glowing Skin: A Complete Guide for All Skin Types

NathTech Guide , Introduction: glowing skin is a reflection of overall health and self-care. While…

3 months ago

How to Get Glowing Skin: Essential Tips, Skin Care Components, and Protection Against Environmental Factors

NathTech Guid Introduction: Achieving glowing skin is a goal that many people aspire to, but…

3 months ago

Essential Components of Fitness: A Comprehensive Guide for All Ages

Nathtech Guideline , Introduction Maintaining fitness is crucial for a healthy and fulfilling life, regardless…

5 months ago

Maintaining Fitness Naturally: A Comprehensive Guide for All Ages

Nathtech Guideline ,   Introduction ; In today's fast-paced world, maintaining fitness is more than…

5 months ago

Unlocking Natural Fitness: Essential Tips for Every Age

Nathtech's Guideline ,     Introduction , In a world that is increasingly focused on…

5 months ago