Re: [xmljs-users] .removeChild() syntax - just can't get it right...
Brought to you by:
djoham,
witchhunter
From: David J. <dj...@ya...> - 2005-08-25 16:33:39
|
Hi Barry, The problem is that the variable "addresses" is a DOMNodeList (returned from getChildNodes). A DOMNodeList doesn't support removeChild. Basically, you need to get yourself a reference back to the addresses node so you can call removeChild. Hope this helps! David --- Barry Beattie <ba...@ta...> wrote: > Hi all > > the error is "object doesn't support this property or method" > > but I'm trying to remove a node (and it's children) and just can't land it on the correct node. > Any idea what I'm doing wrong? I can see (alert) the correct node to remove but... (using W3C > DOM) > > thanx > barry.b > > code > =========== > function clearaddress(element_id){ > var ele = document.getElementById(element_id); > var clearAddrNum = ele.options[ele.selectedIndex].value; > var addressRoot = masterXmlDoc.getDocumentElement(); > var addresses = addressRoot.getElementsByTagName("addresses").item(0).getChildNodes(); > var addrBlock, address; > alert(masterXmlDoc); > for(var i=0;i<addresses.length;i++){ > if(addresses.item(i).getAttribute("add_num")==clearAddrNum){ > address = addresses.item(i); > alert(address) > addresses.removeChild(address); > break; > }//if > }//for > } > > XML schema(eg: want to remove address where add_num="2") > ======================================================== > <?xml version="1.0" encoding="UTF-8" ?> > <entity> > <addresses> > <address add_num="1"> > <address_name1 required="true"> > <![CDATA[ Gomez Addams ]]> > </address_name1> > </address> > <address add_num="2"> > <address_name1 required="true"> > <![CDATA[ Fester Addams ]]> > </address_name1> > </address> > </addresses> > </entity> > > > > > cheers > barry.b > > > > > ------------------------------------------------------- > SF.Net email is Sponsored by the Better Software Conference & EXPO > September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA > Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users > |