Hi,
personally, since it's possible in modern browsers, I would put the svg 
directly in html.
And you can load and parse your file with an ajax call :

var r = new XMLHttpRequest();
r.open("GET", "myFile.svg",true);
r.onreadystatechange = function () {

   if (this.readyState != 4 || this.status != 200) return;

   var parser = new DOMParser();
   var doc = parser.parseFromString( this.responseText, "image/svg+xml");
   var svg = doc.documentElement;
   document.getElementById("myHtmlContainer").appendChild(svg);
};
r.send();


Yannick

----- Mail original -----
De: "[email protected]" <[email protected]>
À: [email protected]
Envoyé: Dimanche 18 Novembre 2012 22:18:54
Objet: [svg-developers] Re: Loading SVG images dynamically and then accessing 
the dom








--- In [email protected] , "Pranav Lal" <pranav.lal@...> wrote: 
> 
> Hi Marty, 
> Many thanks for your message. 
> <snip you can 
> access the svg dom directly from the html script if you prefer. 
> PL] Do you have any pointers on how to do this? 
> 
> Pranav 
> 

Hi Pranav, 

I think we do the same thing that you are talking about. We use the embed tag 
like Marty suggested to you. When we bring in the file from the server, we 
parse it to the DOM. We do that with the dump() command, but the syntax varies 
with the browser. We put the entire file into a single group, then we attach 
the group to the DOM. A key question is whether you want to work with the file 
once you load it. 

Our embed tag looks like this. 

<embed id="hom_img" width="744px" height="652px"' 
'type="image/svg+xml" src="home_imgs.svg">' 

We establish the element we attach to like this. 

htmlObjImgs = document.getElementById("hom_img"); 
SVGDocImgs = htmlObjImgs.getSVGDocument(); 
SVGRootImgs = SVGDocImgs.documentElement; 

Then we attach the group to SVGRootImgs 





------------------------------------

-----
To unsubscribe send a message to: [email protected]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
----Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to