[jdom-interest] (no subject)
Ian Lea
ian.lea at blackwell.co.uk
Thu Jul 12 01:57:21 PDT 2001
Sounds odd. Are you sure you are working with the same
instance of doc throughout? It might be easier for people
to help if you posted the smallest possible complete
program and xml file that demonstrated the problem.
And are you using jdom b7? You are unlikely to get
help if not.
--
Ian.
rgulati at cya.com wrote:
>
> 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