thx alot for your help. i've testing some code of my own and i'm starting to understand this shit :) but i'm struggling with one more thing. i can't get the script to return a DOM Node. i need it to do so in order to be able to use certain properties and methods. it only returns DOM Element, Dom Document and DOM Nodelist.
Here's the code i use. I've tried to catch the different outputs when running different methods on the parseXML-result, but I can't seem to get a Node as an output. this is the only thing i need to fix in order to make this work perfectly. i call the funstion loadFile with the dataBase.xml as argument function loadFile (fileName) { getURL(fileName, fileLoaded); } function fileLoaded (data) { var msg = ''; if(data.success) { XMLTree = parseXML(data.content); XMLTree = XMLTree.documentElement; XMLTree = XMLTree.getElementsByTagName ("products"); alert(XMLTree); alert(XMLTree.length); alert(printNode(XMLTree.item(0))); } else { msg = 'Loading has failed'; } } > Oh, right. Well that's not too hard either. Just do a depth first > traversal of the nodes, building some SVG elements as you go. > > function traverse(n, level, count) { > // create a text element for each element and text node > var t = document.createElementNS ("http://www.w3.org/2000/svg", "text"); > var label; > if (n.nodeType == 1) { > // elements use their tag name and id as the label > label = n.tagName + "#" + n.getAttributeNS(null, "id"); > } else if (n.nodeType == 3) { > // text nodes just use the node value > label = n.nodeValue; > // unless it's empty, when we skip it > if (label.match(/^\s*$/)) { > return count; > } > } else { > // ignore other nodes > return; > } > // position the text based on the current level, and the count of > // how many text elements we've done > t.setAttributeNS(null, "x", level * 100); > t.setAttributeNS(null, "y", count * 20); > t.appendChild(document.createTextNode(label)); > document.documentElement.appendChild(t); > // recursively go through each child node > for (var m = n.firstChild; m != null; m = m.nextSibling) { > count = traverse(m, level + 1, count + 1); > } > // return what the new count is up to > return count; > } > > traverse(testNode, 0, 1); > > Untested, but if it doesn't work, it should be nearly right. :-) > > Cameron > > -- > Cameron McCormack > | Web: http://mcc.id.au/ > | ICQ: 26955922 ------------------------ 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/