[jdom-interest] (no subject)
rgulati at cya.com
rgulati at cya.com
Wed Jul 11 14:12:28 PDT 2001
hi,
i have a problem using Jdom while reading form a file and delete a node and
then write to file again. it's not deleting the node. while Individually bith
method workd fine. If i am writing and then deleting works fine. if reading then
writing does not work.
this is write Method.
XMLOutputter output = new XMLOutputter(" ", true);
FileWriter writer = new FileWriter(fileName);
output.output(doc, writer);
writer.close();
This is read Method.
this.doc = null;
FileInputStream fis = new FileInputStream(fileName);
SAXBuilder builder = new SAXBuilder();
doc = builder.build(fis);
fis.close();
This is delete Method.
Element root = doc.getRootElement();
List list = root.getChildren(nodeDesc.nodeName());
int index = -1;
for (int i = 0; i < list.size(); i++) {
Element temp = (Element)list.get(i);
String attValue =
(temp).getAttributeValue(nodeDesc.checkAttributeName());
if (attValue.equals(nodeDesc.checkAttributeValue())) {
index = i;
break;
}//if
}//for
if (index!= -1) {
Element nodeLvlOne = (Element)list.get(index);
rootNode.removeContent(nodeLvlOne);
}
may be if you could help me in this. Individual everything is working But bot
read method Then delete and then Write method thar doesnot work.
Thanks
Renu Gulati
More information about the jdom-interest
mailing list