OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   document.removeChild(node child)

[ Lists Home | Date Index | Thread Index ]
  • From: Mark Cheek <mcheek@NetVendor.com>
  • To: "'listserv:java-xml list'" <java-xml-interest@cybercom.net>, "'listserv:xml-dev list'" <xml-dev@ic.ac.uk>
  • Date: Tue, 3 Aug 1999 18:55:52 -0400

can anyone explain to me either:
	1::why my code throws an exception OR
	2::how to remove a node from a Document object
?
I have a Document object that was instantiated using a DOM
implementation while parsing an XML file.. whenever I try to remove one
of the leaves from the Document object, I always receive an exception
at: 
DOMExceptionImpl

thanks for your time,
-mark

---------CODE IS BELOW THIS LINE-----------
		public void deleteNode(MutableTreeNode node)
		{
			//delete node from model
			System.out.println(node.toString());
			removeNodeFromParent(node);
			fireTreeNodesRemoved(this,new
Object[]{getRoot()},new int[0], new Object[0]);

			Node aNode = this.getNode(node);
			System.out.println(aNode.toString());
			System.out.println(nodeMap.toString());

			//loop through document and match node??
			NodeList zList =
document.getElementsByTagName("item");
			for(int z=0;z<zList.getLength();z++)
			{

System.out.println(zList.item(z).getNodeName());

System.out.println(zList.item(z).getNodeType());

System.out.println(zList.item(z).getNodeValue());

				if(zList.item(z).hasChildNodes())
				{
					NodeList yList =
zList.item(z).getChildNodes();
					for(int y
=0;y<yList.getLength();y++)
					{

System.out.println(yList.item(y).getNodeName());	//=#text

System.out.println(yList.item(y).getNodeType());	//=3

System.out.println(yList.item(y).getNodeValue());	//here=OrderNo
						String value =
yList.item(y).getNodeValue();

if(value.equals(node.toString()))
						{
                            try
                            {
                                document.removeChild(yList.item(y));
//<=EXCEPTION THROWN HERE!
                            }
                            catch(Exception e)
                            {
                                e.printStackTrace();
                            }
						}
					}
				}
			}

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS