Our system loads SVG files programmatically into HTML via AJAX. A typical SVG file begins with:
Above receipes gave me all zeros for the x, y, width and height viewBox attributes -- unless at least one of them was changed programmatically.
I finally succeded with
var width = document.getElementById("mysvg").getAttribute("width");