473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

removeChild() function

hi there...

i really need your help..
i develop a calendar event using java. all event that i insert will be saved into xml file. But, i have problem when trying to remove the event that i saved. Can somebody tell me how to remove elements in xml file?

this is my xml file:-
<?xml version="1.0" encoding="UTF-8"?>
<Calendars>
<events><eventID>E012</eventID><date>01012006</date><event>my birthday...now i'm 24...</event></events>
<events><eventID>E013</eventID><date>02022006</date><event>birthday aril</event></events>
<events><eventID>E014</eventID><date>04042006</date><event>birthday razak</event></events>
<events><eventID>E015</eventID><date>01072006</date><event>birthday apis</event></events>
<events><eventID>E016</eventID><date>14072006</date><event>birthday syuhada</event></events>
</Calendars>

this is my java code:-
File docFile = new File("calendarEvent.xml");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = null;
doc = db.parse(docFile);

Element root = doc.getDocumentElement();//Element element = (Element)doc.getElementsByTagName("junk").item(0);
NodeList children = root.getChildNodes();
int indexID = 1;
for (Node child = root.getFirstChild(); child != null; child = child.getNextSibling())
{
if (child.getNodeType() == child.ELEMENT_NODE) {
Node child2 = child.getFirstChild();
String test = child2.getFirstChild().getNodeValue();

if (test.equals(eventID))
{

for (Node child1 = child.getFirstChild(); child1 != null; child1 = child1.getNextSibling())
{
child1.removeChild(child1.getFirstChild()); }
}
}
}
Sep 21 '06 #1
0 2375

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: bulk88 | last post by:
How can I emulate DOM level 1 removeChild in IE 4? I already figured out to emulate getElementById by doing this if((!document.getElementById) && document.all) {document.getElementById =...
1
by: JehanNYNJ | last post by:
I need to clear out the HTML contents of a <span> element and then re-add that element as a blank span. Here is the code... var elem = document.getElementById(spanId); var deletedElem =...
2
by: Stewart | last post by:
Originally posted in comp.lang.javascript: Newsgroups: comp.lang.javascript From: "Stewart" Date: 23 Aug 2005 02:50:04 -0700 Local: Tues, Aug 23 2005 10:50 am Subject: FireFox, RemoveChild,...
4
by: VA | last post by:
I have the following code (modified) from RobG on this newsgroup... function moveColumn(table_id,col_id, dir) { var table=document.getElementById(table_id); var idx=GetCellIndex(col_id,table);...
1
by: Rebecca Tsukalas | last post by:
Hello, I have a problem concerning removeChild. This is the XML structure I use with php: <xml_thing <language1 <site>bla1</site <site>bla2</site <site>bla3</site </language1
6
by: VK | last post by:
I must be missing something very obvious, but my nightly head doesn't work anymore. Press "Insert" button to add <insnodes after each <br>. Now press "Delete" - only even <insare being removed....
5
by: tader | last post by:
Hi, so i got script like that var div_box = document.createElement("div"); div_box.setAttribute("id", "music_box"); div_box.style.top = (Number(cords) - 10) + "px"; div_box.style.left =...
10
by: r_ahimsa_m | last post by:
Hello, On index.html page I have a table with id="property_fields". <table id="property_fields" name="property_fields" border="0"> It contains set of rows with the following IDs: var...
5
by: r_ahimsa_m | last post by:
Hello, I am lerning HTML/CSS/JavaScript. I created HTML page with table "property_fields" containing 24 rows ('tr' elements). I want to remove last 23 rows: var table =...
7
by: ChuckB via WebmasterKB.com | last post by:
Hello. I'm trying to remove an additional radio selection if another radio button is selected. There's suppose to be two additional selections if one particular button is chosen. Then if the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.