Parsing XML files : exception with JDOM

Put your problem here if it does not fit any of the other categories.

Parsing XML files : exception with JDOM

Postby grumpy » Wed Nov 10, 2010 10:12 am

Consider th following code :
static org.jdom.Document document;

File xmlConfigFile;
SAXBuilder sxb =new SAXBuilder();
try
{
xmlConfigFile = new File("myconfig.xml");
document = sxb.build(xmlConfigFile);
}
catch (Exception e){
e.printStackTrace();
}


On the line " document = sxb.build(xmlConfigFile) ", I get a StringIndexBoundsException under Android :( . And this code works under "classical java :) .

I'm working with the last sdk, under eclipse for windows.

Thanks for your help.

Grump
User avatar
grumpy
Freshman
Freshman
 
Posts: 5
Joined: Wed Nov 10, 2010 9:49 am
Location: Belgium

Top

Re: Parsing XML files : exception with JDOM

Postby blundell » Wed Nov 10, 2010 5:14 pm

Do you have some qwerky characters in your input file?
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: Parsing XML files : exception with JDOM

Postby grumpy » Wed Nov 10, 2010 10:44 pm

The content of the file :
<?xml version="1.0" encoding="UTF-8"?>
<dictionnaries>
<dict dname="Littré">
<file>littre.xml</file>
<path>littre</path>
<parse>littreconf.xml</parse>
</dict>
<dict dname="Antidote">
<file>druide.xml</file>
<path>druide</path>
<parse>druideconf.xml</parse>
</dict>
</dictionnaries>


Nothing special ! :cry:
User avatar
grumpy
Freshman
Freshman
 
Posts: 5
Joined: Wed Nov 10, 2010 9:49 am
Location: Belgium

Re: Parsing XML files : exception with JDOM

Postby blundell » Wed Nov 10, 2010 10:49 pm

Are you sure that's where your error is being thrown, since the code you pasted just catches a general exception?
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: Parsing XML files : exception with JDOM

Postby grumpy » Wed Nov 10, 2010 11:00 pm

I catched more than one exception. I reduced them for a most cromprehensive code. The other possible exceptions were an IOException or a JDOMxception. But they were not catched.
So....
User avatar
grumpy
Freshman
Freshman
 
Posts: 5
Joined: Wed Nov 10, 2010 9:49 am
Location: Belgium

Re: Parsing XML files : exception with JDOM

Postby grumpy » Thu Nov 11, 2010 1:55 pm

I'v seen this exception in several forum, but I never seen a real response. :?
User avatar
grumpy
Freshman
Freshman
 
Posts: 5
Joined: Wed Nov 10, 2010 9:49 am
Location: Belgium

Top

Re: Parsing XML files : exception with JDOM

Postby grumpy » Mon Nov 15, 2010 9:15 am

Nobody to tell me the way of heaven with jdom ?
User avatar
grumpy
Freshman
Freshman
 
Posts: 5
Joined: Wed Nov 10, 2010 9:49 am
Location: Belgium

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 14 guests