javascript - get svg element from an xml response -


when try access reponse xml errors. want access svg firstly , height , width of svg viewbox or alternative way. how can access svg response xml height , width?

i want access height , width using javascript (maybe jquery) so:

this._imagew = jquery(".svgimage").width(); this._imageh = jquery(".svgimage").height();

i using method download file , give me response in xml. idk how access elements withing xml reponse thought.

enter image description here

this reponse above. tried in console doesn't work enter image description here

how can access height , width of svg element?

you're going want parse string c html using jquery function $.parsehtml().

from that, have variable can accessed getelementbyx() calls , can find svg element want.

var c = '<svg width="200px" height="100px" viewbox="0 0 100 50"> <path d="m50,35 a20,20 0 1,0 0,-20 a20,20 0 1,0 0,20z" fill="white" stroke="black"></path> </svg>'    var html = $.parsehtml(c);    $('#width').html($(html).attr('width'));    $('#height').html($(html).attr('height'));    $('#output').html($(html));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <p>height: <span id="height"></span>  </p>  <p>width: <span id="width"></span>  </p>    <div id="output"></div>


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -