Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access innerText of svg element

Status
Not open for further replies.

minasharif

Programmer
Oct 14, 2006
5
Hi;
I have a XML document and going to transform it as HTML by XSLT. One of the fields named "graph" consists of SVG image code. I have added an EMBED object to the output HTML as below:

<embed type='image/svg+xml' src='Image.svg' onload="this.getSVGDocument().getElementsByTagName('svg')[0].innerText = '{graph}'" />

Image.svg is:

<?xml version="1.0" standalone="no"?>
<?xml-stylesheet href="SVG.css" type="text/css"?>

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "
<svg width="100%" height="100%" version="1.1" xmlns=" />

But unfortunately, I may not access the innerText or innerHTML of svg element in Image.svg; Although I can read or change the attributes of this element such as "width" or "version"!?
How would I be able to show the svg image? I am looking for a way to change the innerText of svg tag from the main HTML file.
Much obliged to you for your attention.

Regards
 
innerText does not exist in the dom standard at any level. If you do the testing on ff for better svg support the moment, you can try this. ("Try" because your description is complete fragmented as if you're hiding something - and that's fine for me. I will therefore give you a cryptic response and if you see through it that means you have a good grip of the problem.)
[tt]
onload="this.getSVGDocument().documentElement.appendChild((new DOMParser()).parseFromString('{graph}','text/xml').documentElement)"
[/tt]
It is squeezed into a one-liner as your attempt.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top