JSFiddle - React, Tailwind, and code Playground
JavaScript
$(function( $ ) {
var all = {};
(function( app ) {
app.init = function() {
app.xml = '<Circuit><C Type="Bipolar" Name="c1"><Cathode row="10" col="20"/> <Anode row="15" col="50"/></C><AND Name="and1"><Input><Pin row="10" col="40"></Pin> <Pin row="20" col="40"></Pin></Input><Output><Pin row="30" col="50"></Pin></Output></AND><Diode Name="d1" Value="30"><Anode row="30" col="50"></Anode><Cathode row="40" col="60"></Cathode></Diode><R Type="Constant" Name="r1"><Node row="60" col="80"></Node><Node row="70" col="80"></Node></R></Circuit>';
app.oxml = $( $.parseXML( app.xml ) );
};
app.getAll = function() {
return app.oxml.find('*').map(function(v,i) {
var ux = {};
$.each( this.attributes, function(index, node) {
ux[ node.nodeName ] = node.nodeValue;
});
return $.extend({},{ nodeName: this.nodeName }, {attributes:ux});
})
.get();
};
})( all );
all.init();
console.log( JSON.stringify(all.getAll()) );
});