lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,



I was very excited to see LuaJava - A very good way to have the power and
beauty of Lua combined with libraries and ubiquity of Java.



I thought I would try a short program to see how it operated:



documentBuilderFactory =
luajava.bindClass("javax.xml.parsers.DocumentBuilderFactory")

factory = documentBuilderFactory:newInstance()

builder = factory:newDocumentBuilder()

document = builder:parse("labels.xml")

root = document:getDocumentElement()

print(root:toString())



This worked beautifully (I'm using Java 1.4.1 on Windows XP) with the file
labels.xml:

<?xml version="1.0" encoding="iso-8859-1"?>

<labels>

  <label added="2003-06-20">

    <quote>

      <!-- Mixed content -->

      <emph>Midwinter Spring</emph> is its own season&#133;

    </quote>

    <name>Thomas Eliot</name>

    <address>

      <street>3 Prufrock Lane</street>

      <city>Stamford</city>

      <state>CT</state>

    </address>

  </label>

  <label added="2003-06-10">

    <name>Ezra Pound</name>

    <address>

      <street>45 Usura Place</street>

      <city>Hailey</city>

      <state>ID</state>

    </address>

  </label>

</labels>



However, when I added the following line to the program:

nodelist = root:getElementsByTagName("label")



I get this error:

xmltest.lua:7: Class luajava.LuaJavaAPI can not access a member of class
org.apache.crimson.tree.ParentNode with modifiers "public"

luajava.LuaException: Error on file xmltest.lua

        at luajava.Console.main(Console.java:24)



I would really appreciate it if anyone could tell me what I am doing wrong.



Thanks,



Martin