I am confused between SAX, XMLConfigService and ContentService:
- I can overwrite on my xml file contained in admin space with the ContentService:
ContentWriter writer = contentService.getWriter(recordRef, ContentModel.PROP_CONTENT, true);
writer.setMimetype("text/xml");
writer.setEncoding("UTF-8");
String content="blabla";
writer.putContent(content);
- But I would like not to overwrite but write in my xml file at a specific xplace between the tags <function> </function> contained in the tags <specialFields></specialFields> So for this I was thinking of using SAX:
SAXReader xmlReader = new SAXReader();
File xmlFile = new File(url);
Document doc = xmlReader.read(xmlFile);
Element root = doc.getRootElement();
SAXReader xmlReader = new SAXReader();
File xmlFile = new File(url);
Document doc = xmlReader.read(xmlFile);
Element root = doc.getRootElement();
But then should I write inside using ContentWriter or SAXWriter? How will I tell my parser where to write?
Thanks in advance