Reading and writing XML files the easy way in Notes 8

If you are writing plugins for Notes 8 or any Eclipse based product and need to read and write XML files you should check out XMLMemento first. The class allows you to easly store XML files as cache or read XML files and work with a pretty simple API set when manipulating the DOM.

Here is a sample code snippet for how you can read the XML into an XMLMemento object:

XMLMemento xml;

BufferedReader in = new BufferedReader(new FileReader(f.getAbsolutePath()));

xml = XMLMemento.createReadRoot(in);


You can then modify the XML DOM with with the basic API’s

IMemento[] profiles = xml.getChildren("profile");

for (int p=0; p

Lastly, you can then easily write the XML back from the model using the save API:

BufferedWriter out;

try {

    out = new BufferedWriter( new FileWriter(f.getAbsolutePath()));;

} catch (IOException e) {

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.