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