hi,

serverside line per line and templated based generation are probably 
best. regarding client side DOM manipulations with SVG there is no big 
difference in performence between

1)

elem = document.createElement(elem_type);
elem.setAttribute(NS,attr_1,val_1
[...]
elem.setAttribute(NS,attr_n,val_n);
doc.appendChild(elem);

and

2)

doc.appendChild(parseXML("<elem_type attr1_1='val_1' [...] 
attr1_n='val_n'/>",doc));

ressource demanding is only the DOM manipualtion itself and this is the 
"append" line in both cases.

when not adding elements but changing them, long chains of 
getElementById(id).setAttribute(NS,attr,val) are often easier to write, 
but erasing, rebuilding and reappending it could be quicker.

andré




-- 
___________________________________________________________________
andre m. winter,
<http://www.carto.net/>
<http://www.vectoreal.com/>
<http://tirolatlas.uibk.ac.at/>


Brady, Phillip schrieb:

> Greetings everyone out there in SVG land!  
> 
>  
> 
> I have an SVG / XML / DOM question I was hoping maybe you folks could offer
> some opinions on.  Basically it is simply when or when not to use DOM to
> manipulate XML (in this case SVG... but also generically speaking)?  As an
> example, I put together a little application in which I am periodically (15
> seconds) constructing an XML file for data output to other processes.  I
> originally wrote this app building the xml file using the dom to create
> elements, append them, etc... piece by piece.  This was also a simple
> educational process for me to learn about the dom.  I then stepped back and
> looked at the output from the perspective of a simple text string and had
> the realization that I could create the same xml file much cleaner and
> simpler (in code at least) simply by building the file line by line, string
> by string... without using the dom at all...  So, my question to you is
> this... in the context of building an xml file... what benefits does using
> the dom offer that simply constructing a text file does not?
> 
>  
> 
> In case I didn't explain myself very well, let me offer an example.
> 
>  
> 
> var dom;
> 
> dom = new ActiveXObject("Microsoft.XMLDOM");
> 
> dom.async = false;
> 
> dom.validateOnParse = false;
> 
> dom.resolveExternals = false;
> 
> var node = dom.createProcessingInstruction("xml", "version='1.0'");
> 
> dom.appendChild(node);
> 
> var root = dom.createElement("root");
> 
> var attr = dom.createAttribute("created");
> 
> var d = new Date();
> 
> attr.value = d.toLocaleString();
> 
> root.setAttributeNode(attr);
> 
> dom.appendChild(root);
> 
>  
> 
> just to create
> 
>  
> 
> <?xml version="1.0"?>
> 
> <root created="Friday, September 17, 2004 12:45:20 PM"/>
> 
>  
> 
> versus
> 
>  
> 
> var fso, tf;
> fso = new ActiveXObject("Scripting.FileSystemObject");
> tf = fso.CreateTextFile("c:\\test.xml", true);
> 
> tf.WriteLine("<?xml version=""1.0""?>") ;
> 
> tf.WriteLine("<root created=""Friday, September 10, 2004 12:45:20 PM""/>") ;
> 
> tf.Close();
>  
> granted... I didn't actually run that code to verify my syntax on
> everything... but you get the idea... using dom it seems the process can get
> a bit convoluted versus simply outputting what you want the XML to be as a
> string.
> 
>  
> 
> 
> 
> [Non-text portions of this message have been removed]
> 
> 
> 
> 
> -----
> 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
> 
> 
> 
>  
> 



------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/1U_rlB/TM
--------------------------------------------------------------------~-> 

-----
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/

<*> 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