File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes how to read french character from XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "how to read french character from XML" Watch "how to read french character from XML" New topic
Author

how to read french character from XML

Achalveer Singh
Greenhorn

Joined: Apr 28, 2008
Posts: 8
hi can anyone please tell me how we can parse french character from xml file .
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Presuming that the XML file has a correct header, with correct "encoding" attribute, you should not have to do anything. If the file contains characters that don't match the stated encoding, it's not a valid XML file.

For instance, a UTF-8-encoded XML files, with "utf-8" as the "encoding" can happily contain French characters, and these will be read straight in to Java Strings correctly.

XML files can also contain Unicode entities, like &#3A85; . Again, your XML parser should deal with these automatically, so they will just arrive in your Java strings.

So what's the problem you're having?
[ April 28, 2008: Message edited by: Peter Chase ]

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Achalveer Singh
Greenhorn

Joined: Apr 28, 2008
Posts: 8
actually i am not able to get the child that contain french character. all child parser is reading except that contain french character.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41508
    
  53
What is "the child"? How are you parsing - DOM or SAX? Can you show us a relevant section of the code that demonstrates the problem?


Ping & DNS - my free Android networking tools app
Achalveer Singh
Greenhorn

Joined: Apr 28, 2008
Posts: 8
i m doing like this ....

Document doc = builder.build(new URL(url));

if(doc != null) {

Element root = doc.getRootElement();
if(root != null) {


List kmlChildren = root.getChildren();
if(kmlChildren != null && kmlChildren.size() > 0){
Iterator kmlChildrenItr = kmlChildren.iterator();
if(kmlChildrenItr.hasNext()) {
Element responseElement = (Element)kmlChildrenItr.next();
if(responseElement != null && "Response".equalsIgnoreCase(responseElement.getName())) {
List responseChildren = responseElement.getChildren();
if(responseChildren != null && responseChildren.size() > 0) {
Iterator responseChildrenItr = responseChildren.iterator();
longLat = new LongLat();
while(responseChildrenItr.hasNext()) {
Element responseChild = (Element)responseChildrenItr.next();
if(responseChild != null && "Placemark".equalsIgnoreCase(responseChild.getName())) {
List placemarkChildren = responseChild.getChildren();


this child place mark contain french character.... but parser is unable to read this child node i m using sax parser
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41508
    
  53
if (responseChild != null && "Placemark".equalsIgnoreCase(responseChild.getName())) {
List placemarkChildren = responseChild.getChildren();

this child place mark contain french character.... but parser is unable to read this child node

So "responseChild.getName()" should contain a French character? Or one of the children of responseChild? As part of the tag name or between tag?

Also, what does "unable to read" mean? Without seeing what the XML looks like, and without knowing which lines of the code have what results, it's hard to advise what to check.

i m using sax parser
This looks like DOM, not SAX.
Achalveer Singh
Greenhorn

Joined: Apr 28, 2008
Posts: 8
one of the placemark child contain french character . not in the tag between tag .
Xml file looks like

<Placemark id="p1">

<address>
66, Rue Pierre Charron, 75008 8�me Arrondissement, Paris, France
</address>

i am getting null pointer exception
at if(responseChild != null && "Placemark".equalsIgnoreCase(responseChild.getName())) {
List placemarkChildren = responseChild.getChildren(); here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to read french character from XML