Results 1 to 2 of 2
Thread: XML with special characters
- 11-06-2009, 11:04 AM #1
Member
- Join Date
- Nov 2009
- Posts
- 2
- Rep Power
- 0
XML with special characters
Hello everyone,
I am trying to do the following:
- I have an XML document located at some place on the web
- I want to get the XMLs content (source) as it is on its location
- The XML file is utf8-encoded
I can do the above, except for that there is 1 odd thing I cannot seem to fix. I can get the XML's source and all that, but whenever it contains special characters such as ö or é, it gets malformed into something else consisting of two characters. I know this has to do with the fact that the XML file is UTF8 encoded and that I am probably reading it using ISO-encoding. However, I have been trying to get to reading it as UTF8, but I cannot succeed.
Anyone know how to do this?
My current code is:
Thanks.Java Code:public String retrieveSource(String link) { String htmlCode = ""; Scanner reader; StringBuilder builder; try { URL url = new URL(link); reader = new Scanner(url.openStream( ) ); builder = new StringBuilder( ); while (reader.hasNext( )) builder.append(reader.nextLine( ) + "\n"); htmlCode = builder.toString( ); } catch (Exception e) { } return htmlCode; }
- 11-06-2009, 02:26 PM #2
Member
- Join Date
- Nov 2009
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
How to index the special characters in Lucene
By talktoudaykumar in forum LuceneReplies: 2Last Post: 04-23-2009, 07:51 AM -
[SOLVED] special characters (ASCII) åäö
By AlejandroPe in forum New To JavaReplies: 8Last Post: 04-06-2009, 10:42 AM -
Searching for Microsoft special characters
By Tim McDaniel in forum EclipseReplies: 2Last Post: 02-24-2009, 03:11 PM -
special characters
By ravian in forum New To JavaReplies: 2Last Post: 11-16-2007, 01:28 PM -
Special characters in text fields
By Felissa in forum Web FrameworksReplies: 0Last Post: 06-27-2007, 04:47 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks