I'm trying to do some XML DOM manipulations in an embedded Jython interpreter that doesn't have access to substantial portions of the standard library. To that end, I'm hoping to make use of the java standard library (to which I have access) and utilize org.w3c.dom
, the DocumentBuilderFactory
, or similar.
The issue is that I have a str
holding the XML response and all of these libraries expect a File or InputStream; normally what I'd do in python is wrap the string in a StringIO
object, but this doesn't cut it in Java land.
Ideas?
Slightly off topic as this is a working Jython sample based on the idea in https://stackoverflow.com/a/562207/1774484 which wraps a string as an InputSource rather than a File, but this can then be used with a DocumentBuilderFactory to produce an org.w3c.dom.Document as requested.
The above code works in Jython 2.2.1, 2.5.3 and 2.7.0.