Hi All,

I'm trying to run the following shippet:

import org.mozilla.javascript.Context;

public class JSSnippet {
  public static void main(String[] argv) throws Exception {
    Context cx = Context.enter();
      try {
        String script = "" +
          "var xml = <root><node1/><node2/><node3/></root>;" +
          "for (var node in xml.*) {" +
" java.lang.System.out.println('>> node: ' + node + '; type: ' + (typeof node));" +
          "}";

        cx.evaluateString(cx.initStandardObjects(), script, "", 1, null);
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        Context.exit();
      }
   }
}

which suppose to print out list of xml nodes. But instead I have the following output:

>> node: 0; type: string
>> node: 1; type: string
>> node: 2; type: string

Can anybody explain this please?

Thanks,
alex

import org.mozilla.javascript.Context;

public class JSSnippet {
        public static void main(String[] argv) throws Exception {
                Context cx = Context.enter();
                try {
                        String script = "" + 
                                "var xml = 
<root><node1/><node2/><node3/></root>;" + 
                                "for (var node in xml.*) {" + 
                                "       java.lang.System.out.println('>> node: 
' + node + '; type: ' + (typeof node));" + 
                                "}";

                        cx.evaluateString(cx.initStandardObjects(), script, "", 
1, null);
                } catch (Exception e) {
                        e.printStackTrace();
                } finally {
                        Context.exit();
                }
        }
}
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to