Coding and node context under MSXML3
Hi. I'm writing code using MSXML3/ASP to do various node creation and processing tasks. I'm having some trouble defining exactly where, who, and when it is best to create nodes/documents. Specifically -- when calling a function which creates a new node, say fetchContentNode(), is it better to: A) Have the caller create an XMLDOMDocument, and pass a context node into the function for the function to create the new node on or as a child of? B) Have the function itself create an XMLDOMDocument, and return the document to the caller, who would then be responsible for appending the returned DOMDocument.documentElement to its own working DOMDocument (or doing something else with it)? C) Have the caller create an XMLDOMDocument and pass it to the function, then have the function return the newly created node -- whose parent is the XMLDOMDocument originally passed in? I'm looking for any advice on "best practices" in this area, because I'm having trouble conceptualizing through the whole process. Option A seems like it would make the best use of resources, however at the cost of being able to control exactly what happens with the newly created node. Option B seems like an unnecessary waste of resources, since you would be instantiating a new DOMDocument every time you wanted the function to create a node for you, which would then be appended to another, pre-existing DOMDocument (presumably). So Option C seems to be a fair medium between the two: it does not require the called function to create a new DOMDocument to carry out its operation. But it also seems rather messy to do it that way, e.g.: [ create a new DOMDocument, xmlDoc, with some children nodes ] Set nodContent = fetchContentNode(xmlDoc, "content-lookup-name") xmlDoc.documentElement.appendChild nodContent Ideas please! :) joel XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format