cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "kal inuganti" <xspu...@hotmail.com>
Subject off topic... removeChild() method...
Date Fri, 30 Mar 2001 18:51:22 GMT
<html><DIV>Dear List Members, </DIV>
<DIV>&nbsp;</DIV>
<DIV>This question is about a method in DOM API. Please ignore this question if you
are looking for something exclusively about cocoon.</DIV>
<DIV>&nbsp;</DIV>
<DIV></DIV>I have a question that I need to be helped with: 
<DIV></DIV>
<DIV></DIV>1. 
<DIV></DIV>
<DIV></DIV>I am trying to delete a node and all its children from a dom tree.
This is the code that I used and it does not work. Please suggest! 
<DIV></DIV>I used the ibm parser and sectionname is a string 
<DIV></DIV>
<DIV></DIV>try{ 
<DIV></DIV>
<DIV></DIV>InputStream is = new FileInputStream(filelocation); 
<DIV></DIV>Parser ps = new Parser(filelocation); 
<DIV></DIV>Document doc = ps.readStream(is); 
<DIV></DIV>
<DIV></DIV>NodeList sections = doc.getElementsByTagName("SECTION"); 
<DIV></DIV>
<DIV></DIV>for(i=0;i<SECTIONS.GETLENGTH();I++){ DIV <> if(sections.item(i).getAttributes().getNamedItem("name").getNodeValue().equals(sectionname))

<DIV></DIV>break; 
<DIV></DIV>} 
<DIV></DIV>Node parent = sections.item(i).getParentNode(); 
<DIV></DIV>System.out.println(parent.getNodeName()); 
<DIV></DIV>
<DIV></DIV>expunge=parent.removeChild(sections.item(i)); 
<DIV></DIV>} 
<DIV></DIV>
<DIV></DIV>Should I write back to the file or something after I do this operation?
or should this automatically delete the section and save the changes to the file? 
<DIV></DIV>
<DIV></DIV>Please Help! 
<DIV></DIV>Kalyan<br clear=all><hr>Get your FREE download of MSN Explorer
at <a href="http://explorer.msn.com">http://explorer.msn.com</a><br></p></html>

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message