Link to home
Start Free TrialLog in
Avatar of dij8
dij8Flag for New Zealand

asked on

XML removeChild error in ASP.

I am going through the Sams ASP in 24 hours and am trying to do the web store (chap 24).  Originally I had a problem when going through my XML using the "BagItems.childNodes" part.  I sorted that by changing it to "BagItems.getElementsByTagName("product")".  This does everything I want.  Except, of course, one thing.  I am now trying to delete a node when a specific value is 0.

The code "BagItems.removeChild(item)" returns the error "The parameter Node is not a child of this Node."  If I change the code above back to "BagItems.childNodes" I get the error "item.attributes.getNamedItem(...)" before it even gets to the  removeChild part (which is why I changed it to "BagItems.getElementsByTagName("product") in the first place).

Can anyone tell me why this isn't working?  And what my alternatives might be.  I can't see why "product" isn't a child node.  And even if that is irrelevant that why "item" isn't a node that can be removed.

I'll cross post this in XML area as well.
Avatar of craig_york
craig_york

Not sure about XML, but this is what I use in asp.

d = document.getElementById("BagItems");
d_nested = document.getElementById("product");
throwaway_node = d.removeChild(d_nested);
Avatar of dij8

ASKER

Unfortunately I can't do that.  That would remove ALL product nodes.  Which there may be many of them.  And I only want to remove a specific item.
ASKER CERTIFIED SOLUTION
Avatar of MMeijer
MMeijer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dij8

ASKER

Thank you MMeijer.

I had just figured that out myself. :-)  All the books I have were of no help.  In the end, DevGuru gave me the idea.

But I know it works, and you came up with the answer, so you get the points.

Is this good or bad coding?  If it works, I guess it's good, right?