XML removeChild error in  ASP.

Posted on 2003-03-22
Medium Priority
Last Modified: 2010-08-05
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.
Question by:dij8
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 8189483
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);
LVL 10

Author Comment

ID: 8189788
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.

Accepted Solution

MMeijer earned 1000 total points
ID: 8192161
The code "BagItems.removeChild(item)" returns the error "The parameter Node is not a child of this Node.",

try "item.parentNode.removeChild(item)" :)
LVL 10

Author Comment

ID: 8192285
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?

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question