bonjour,
je suis entrain de parser un fichier qui contient des informations écrites en français avec ce code:
mais ce type d'erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 public void ClassInfo(String label){ String pathconceptclass="Z:\\concept\\conceptclassFR.xml"; String id; Boolean trouv=false; Boolean trouv2=false; String str1=""; String classid; int i2=0; int j=0; int i1=0; int i3=0; org.w3c.dom.Element racine; Document doc; try { DocumentBuilderFactory factory =DocumentBuilderFactory.newInstance(); DocumentBuilder parser = factory.newDocumentBuilder(); doc = parser.parse(pathconceptclass); racine=doc.getDocumentElement(); NodeList liste = racine.getElementsByTagName("Patentid"); while((i1< liste.getLength()) && (trouv==false)){ org.w3c.dom.Element e = (org.w3c.dom.Element) liste.item(i1); NodeList liste2= e.getElementsByTagName("Classid"); NodeList liste3= e.getElementsByTagName("Classinfo"); //System.out.println(liste3.getLength()); i2=0; i3=0; while ((i2<liste2.getLength()) && (trouv==false)){ org.w3c.dom.Element e2 = (org.w3c.dom.Element) liste2.item(i2); classid=e2.getTextContent(); StringTokenizer st= new StringTokenizer(classid," "); classid=st.nextToken(); if(classid.equals(label)){trouv=true; org.w3c.dom.Element e3 = (org.w3c.dom.Element) liste3.item(i3); System.out.println(e3.getTextContent());} i3++; i2++; } i1++;} } catch(Exception e){System.out.println(" we've got a problem"); e.printStackTrace ();} }
alors que je parse avec le même code le même fichier mais avec des informations écrites en anglais.org.xml.sax.SAXParseException: Invalid byte 2 of 3-byte UTF-8 sequence.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at test.commande.cluto.ManipManualClass.ClassInfo(ManipManualClass.java:455)
at test.commande.cluto.Exec.AnalysClassCluto(Exec.java:409)
at test.commande.cluto.Exec.main(Exec.java:70)
[Fatal Error] conceptclassFR.xml:8:29: Invalid byte 2 of 3-byte UTF-8 sequence.
Partager