?
Solved

Java XML Parse error using UTF-8

Posted on 2007-12-03
5
Medium Priority
?
10,368 Views
Last Modified: 2013-11-23
Hi,
      I have a java porgram that read an XML document from a url. here is an excerp from the XML:

<?xml version="1.0" encoding="UTF-8"?>
<items >
<item font-face="Arial" font-size="30" font-color="16777215">
<![CDATA[BON]]></item><item font-face="Arial" font-size="30" font-color="16777215"><![CDATA[* Disfruta de tus programas favoritos en WAPA Mývil en tu celular de Claro. * * Textea al 29960 * 18+ solamente * Más información www.wapa.tv *]]>
</item>
</items>

 The code that's is reading the file is the following:

DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse("http://65.38.219.91/29960/test/getmessages2.php");

but I got the follwing error when the code have latin charcter like é or á

com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 4-byte UTF-8 sequence.

What can I do?
0
Comment
Question by:cmercado_miranda
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 1500 total points
ID: 20397407
>>Invalid byte 2 of 4-byte UTF-8 sequence.

It probably *isn't* encoded as UTF-8. You need to read it with the correct encoding
0
 

Author Comment

by:cmercado_miranda
ID: 20397441
how can this be possible if the <?xml version="1.0" encoding="UTF-8"?> say this?

this XML is generated dynamically by a php file, do I need to put something in the content type of the php file to?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20397524
>>how can this be possible if the <?xml version="1.0" encoding="UTF-8"?> say this?

That can say whatever it wants. It doesn't mean it's true
0
 

Author Comment

by:cmercado_miranda
ID: 20397651
Yeap. that  whas the porblem.... I for the output of the php file using the utf-8encode() and the java works fine

Thanks!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20399303
:-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question