schnell geschrieben:
import lotus.domino.*;
import java.io.StringReader;
public class JavaAgent extends AgentBase {
public void NotesMain() {
System.out.println("hallo");
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
String xmlIn = "<?xml version=\"1.0\"?><root><kindOfElement>inhalt</kindOfElement></root>";
StringReader sr = new StringReader(xmlIn);
nu.xom.Document doc = null;
//nu.xom.Document doc = new nu.xom.Document(sr);
nu.xom.Builder parser = new nu.xom.Builder();
doc = parser.build(sr);
nu.xom.Attribute bonusAttribute = new nu.xom.Attribute("bonus", "attribute");
nu.xom.Element el = new nu.xom.Element("bonusNode");
el.appendChild("bonus text content");
el.addAttribute(bonusAttribute);
nu.xom.Element root = doc.getRootElement();
root.appendChild(el);
System.out.println(">" + doc.toString());
System.out.println(">>>" + doc.toXML());
} catch(Exception e) {
e.printStackTrace();
}
}
}
getestet in Notes 7.
ABER: Du müsstest erst einmal die xom Library von Elliotte Rusty Harold einbinden.
http://www.xom.nu/
Die xom-1.1.jar. (sieht so aus wie in Screenshot. Der Edit Project Button im Java Projekt.
Läuft. Ich habs getestet.
System.out.println wird in Notes-Menü File:Tools:Show in Java Debug Console ausgegeben.
Wie du siehst generiere ich das nu.xom.Document aus einem String.
Später werden dann mit der xom Api ein Element, 1 Attribut und 1 Textnode hinzugefügt.
Jetzt weiss ich auch, dass meine Lieblings-XML-Library XOM von Eliotte Rusty Harold in Notes 7 funktioniert (hat mich immer schon interessiert). ;D
Gruß Axel
Ergebnis sieht dann so aus:
hallo
>[nu.xom.Document: root]
>>><?xml version="1.0"?>
<root><kindOfElement>inhalt</kindOfElement><bonusNode bonus="attribute">bonus text content</bonusNode></root>
wie man sieht, sind bonusNode, bonus="attribute" und bonus text content an die konkreten Stellen reingefügt worden.