Java- XML retrieved from a web service

pandanarold

New Member
Okay, so what I'm trying to do is create a java program that uses data obtained from a web service. I can get the data, but it's in the format of an XML document, and when I print it to the (Eclipse) console, there are spaces between every letter and the replaceAll method doesn't work. The relevant part of the code is below.\[code\]BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(webAdress).openStream()));String XMLcode = reader.readLine();XMLcode = XMLcode.concat(reader.readLine());XMLcode = XMLcode.replaceAll(" ", "");System.out.println(XMLcode); //in the finished program, I will do something with the data in the XML document.\[/code\]The results look like this-\[code\]t? < ? x m l v e r s i o n = " 1 . 0 " e n c o d i n g = " U T F - 8 " ? >\[/code\]followed by the actual data I'm looking for. Some internet searches implied that the t? meant that this was a text-encoding problem, but all methods I could find for converting UTF-8 into UTF-16 did not help (they do, however, change the t? into ??). Does anybody have any idea how to fix this, or know of a "standard" way to read XML that does not require it available in a file?NOTE- I did not make the web service in question, and as such cannot modify it and don't really know how it works.
 
Back
Top