score:1

Use selectAll() method instead of select() in svgToCan() function there you will get all the list of svgs.

Replace the function svgToCan(){} with these lines

var arr=[];
    for(var i=0;i<d3.selectAll("svg").length;i++){
        arr=d3.selectAll("svg")[i];
        console.log(d3.selectAll("svg")[i]);
    }
     for(var j=0;j<arr.length;j++)
        var svg = arr[j],
        img = new Image(),
        serializer = new XMLSerializer(),
        svgStr = serializer.serializeToString(svg);

For your reference i have attached my jsfiddle example.

https://jsfiddle.net/achuakshuu/L92ngrrd/


Related Query