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.
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.
`; } }
NathTech Guid, Introduction to Toncoin (TON) Toncoin (TON) is the native cryptocurrency of The…
NathTech Guide , Introduction: glowing skin is a reflection of overall health and self-care. While…
NathTech Guid Introduction: Achieving glowing skin is a goal that many people aspire to, but…
Nathtech Guideline , Introduction Maintaining fitness is crucial for a healthy and fulfilling life, regardless…
Nathtech Guideline , Introduction ; In today's fast-paced world, maintaining fitness is more than…
Nathtech's Guideline , Introduction , In a world that is increasingly focused on…