• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to read french character from XML

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi can anyone please tell me how we can parse french character from xml file .
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Achalveer Singh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
actually i am not able to get the child that contain french character. all child parser is reading except that contain french character.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Achalveer Singh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic