I have this kind of XML File.
<?xml version="1.0" encoding="utf-8"?>
<Test1>
<typ>task</typ>
<datestamp>20150602153306</datestamp>
<datecreate>20150602153306</datecreate>
<task uuid="92F7F685-C370-4E55-9026-020E3CDCEDE0" status="0">
<task_headline>TEST2000</task_headline>
<task_subject>There is a Problem.</task_subject>
<task_action>Solve it!</task_action>
<task_priority color="#E62C29">high</task_priority>
<task_status>200</task_status>
<task_note></task_note>
</task>
<task uuid="92F7F685-C370-4E55-9026-020E3CDCEDE0" status="0">
<task_headline>TEST3000</task_headline>
<task_subject>Another Problem</task_subject>
<task_action>Solve it again.</task_action>
<task_priority color="#E62C29">high</task_priority>
<task_status>200</task_status>
</task>
</Test1>
This is a example File, so the uuid is in that case equal.
I want to search for a uuid and set the status to 1000.
What I have tried so far:
SAXBuilder builder = new
org.jdom2.Document document = builder.build(new FileInputStream(new File(fileDir,filenameWithExt)));
org.jdom2.Element rootNode = document.getRootElement();
org.jdom2.Element task1 = rootNode.getChild("task");
task1.getAttribute(taskItems.get(position).get(task_uuid)).setValue("1000");
This is how I create the File:
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(new FileOutputStream(new File(fileDir, filenameWithExt)));
transformer.transform(source, result);
But this still not works. How can I search for an Attribute to edit another Attribute?
I hope you understand what I want to do.
Kind Regards