I think you need:
         "for each (var node in xml.*) {" +
instead of:
         "for (var node in xml.*) {" +

The former loops through the /values/ of the XMLList. The latter just loops through the array indices.

Kieran



Alex wrote:
And result is the same if I do

  var xml = new XML('<root><node1/><node2/><node3/></root>');

instead.


Alex wrote:
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

_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to