Here you can find the source of objectToXMLString(Object xml)
public static String objectToXMLString(Object xml)
//package com.java2s; /*//w ww. ja va2s. c om * Helma License Notice * * The contents of this file are subject to the Helma License * Version 2.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://adele.helma.org/download/helma/license.txt * * Copyright 1998-2003 Helma Software. All Rights Reserved. * * $RCSfile: XmlUtils.java,v $ * $Author: hannes $ * $Revision: 1.4 $ * $Date: 2003/10/22 16:34:06 $ */ import org.mozilla.javascript.Context; import org.mozilla.javascript.Function; import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.ScriptableObject; public class Main { public static String objectToXMLString(Object xml) { String xmlStr; if (xml instanceof String) { xmlStr = (String) xml; } else if (xml instanceof Scriptable) { Scriptable xmls = (Scriptable) xml; Context cx = Context.getCurrentContext(); boolean exitContext = false; if (cx == null) { cx = Context.enter(); exitContext = true; } try { Object func = ScriptableObject.getProperty(xmls, "toXMLString"); xmlStr = (String) ((Function) func).call(cx, xmls, xmls, new Object[] {}); } catch (Exception ex) { xmlStr = ""; } finally { if (exitContext) { Context.exit(); } } } else { xmlStr = xml.toString(); } return xmlStr; } }