Subj : Re: constructing XML properties for host object To : andrei From : Igor Bukanov Date : Fri Dec 31 2004 01:31 am andrei@tchijov.com wrote: > It looks like this code does what I need. > > Node node = ...; > XmlObject xmlObject = XmlObject.Factory.parse( node ); > Object[] args = new Object[1]; > args[0] = xmlObject; > result = ScriptRuntime.newObject( globalScope.get( "XML", globalScope > ), cx, this, args ); > > Is it the "right way"? No: you should not use ScriptRuntime since its is NOT a part of public API and its methods are public purely for technical reasons. Use the following code instead: Node node = ...; XmlObject xmlObject = XmlObject.Factory.parse( node ); Object[] args = new Object[1]; args[0] = Context.javaToJS(xmlObject, globalScope); result = cx.newObject(globalScope, "XML", args); Note that it important to call Context.javaToJS to convert xmlObject to the proper boxed object that XML constructor can handle properly. Regards, Igor .