[jdom-interest] SaxBuilder error: root element missing

Bill Woodward wpwood at saifa.net
Wed Oct 8 06:44:56 PDT 2003


Emmanuel Gilmont said:
>
> //- this doesn't work
> SaxBuilder sb = new SaxBuilder();
> Document doc = sb.build(getClass().getResource("/ressources/tpc.xml"));
>

Are you sure that the URL you are getting is good?  For what it's worth ,
the code I use to get a URL to an XML file in a jar is and build a JDOM
tree with it is:

URL schemaUrl =
    Thread.currentThread().getContextClassLoader().getResource
        ("META-INF/ObjectSchema.xml");
Reader schemaReader = new InputStreamReader(schemaUrl.openStream());
sb.build(schemaReader);

- Bill


      /------------------------------------\
     /   Bill Woodward (wpwood at saifa.net)   \
     \        http://www.saifa.net          /
      \------------------------------------/



More information about the jdom-interest mailing list