(Disclaimer: Using Rhino Inside RingoJS)
Let's say I have a document with an element, I donβt see how I can add nodes as a string to this element. To parse the string into xml nodes and then add them to the node, I tried to use documentFragment, but I could not go anywhere. In short, I need something as simple as .NET.innerXML, but this is not in java-api.
var dbFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); var dBuilder = dbFactory.newDocumentBuilder(); var doc = dBuilder.newDocument(); var el = doc.createElement('test'); var nodesToAppend = '<foo bar="1">Hi <baz>there</baz></foo>'; el.appendChild(???);
How can I do this without using any third-party library?
[EDIT] This is not obvious in the example, but I should not know the contents of the variable 'nodesToAppend'. Therefore, please do not point me to tutorials on how to create elements in an XML document.
source share