?
Solved

XML removeChild error in  ASP.

Posted on 2003-03-22
4
Medium Priority
?
387 Views
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.
0
Comment
Question by:dij8
  • 2
4 Comments
 

Expert Comment

by:craig_york
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);
0
 
LVL 10

Author Comment

by:dij8
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.
0
 
LVL 5

Accepted Solution

by:
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)" :)
0
 
LVL 10

Author Comment

by:dij8
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?
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

569 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