dij8
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.getElementsByTag Name("prod uct")". 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.getNamedI tem(...)" before it even gets to the removeChild part (which is why I changed it to "BagItems.getElementsByTag Name("prod uct") 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.
The code "BagItems.removeChild(item
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
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?
d = document.getElementById("B
d_nested = document.getElementById("p
throwaway_node = d.removeChild(d_nested);