JSFiddle - React, Tailwind, and code Playground

HTML

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
    <text x="0" y="15" fill="black">An SVG element.</text>
</svg>

JavaScript

// brute force:
// alert($('<div>').append($("svg").clone()).html());

var svg = $('svg')[0], attributeMap = {};
for (var k in svg.attributes) attributeMap[svg.attributes[k].name] = svg.attributes[k].value;

function isInterestingKey(k) {
     return (k == 'x' || k == 'y' || k == 'fill');   
}
for (var i = 0; i < svg.childNodes.length; i++) {
    var child = svg.childNodes[i];
    if (child.nodeType == 1) {
        console.log(child.tagName);
        $.each(child.attributes, function (k, v) {
            if (isInterestingKey(v.name)) console.log(v.name+'='+v.value);
        });
    }
}