parsing xml exception

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

parsing xml exception

Postby asolanki » Wed Nov 25, 2009 11:00 am

hello!!!
i am trying to read response from http in xml format. and parsing that xml by SAXParser.
now the problem is its showing exception at some lines.
ParserException: xml is not well formed

in my xml file there are some characters written in different languages like spanish and all. so at that character the parser shows error
now what i can do to overcome this exception
PLease help. its urgent

Thanks ....
Happy coding
asolanki
Senior Developer
Senior Developer
 
Posts: 151
Joined: Thu Jan 08, 2009 7:32 am

Top

Postby qlimax » Wed Nov 25, 2009 6:53 pm

the "trick" must be in the xml file. :)
can you post the whole xml?
¯`·.¸¸.><((((º>¯`·.¸¸. ><((((º>
User avatar
qlimax
Master Developer
Master Developer
 
Posts: 271
Joined: Mon Aug 31, 2009 10:54 am
Location: Swiss

Postby asolanki » Fri Nov 27, 2009 11:09 am

thanks for the reply...
i solved that problem.
i was writting xml file by the method wrieBytes so it was creating problem.
now its solved as i wrote with wrtiechars.

but now another problem is i am getting string between <title> tag. but if "&" character is there in the string then it just takes string till
"&" character comes.

example
<title> hello & world</title>

then it gives string="hello" only.

i want whole string.
please if u can give any suggestion.

thanks
asolanki
Senior Developer
Senior Developer
 
Posts: 151
Joined: Thu Jan 08, 2009 7:32 am

Postby padde » Fri Nov 27, 2009 3:08 pm

You have to replace chars like that.. google for chars you have to encode.
The '&' char for example is encoded to "&amp;". Or you could use a CDATA
section.. but you could google that too ;)
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby asolanki » Mon Nov 30, 2009 6:59 am

thanks a lot for the reply.
but this xml i am taking from http response. since i knw i cant modify in it.
so i think using different xml parser may be the solution. or u can suggest something else...


thanks.
asolanki
Senior Developer
Senior Developer
 
Posts: 151
Joined: Thu Jan 08, 2009 7:32 am

Postby padde » Mon Nov 30, 2009 7:24 am

Make sure you get the xml with something like "setHeader("Content-Type", "application/x-www-form-urlencoded");"
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 12 guests