Bonjour,

je cherche à accéder à la valeur spécifique d'un élément pour l'afficher, mais je n'y arrive pas.

Voici mon fichier xml

Code xml : 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
47
48
49
50
51
52
53
54
55
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<!--
  EB_IS_2009: Editorial boards of Information System journals (JCR 2009 edition)
  @version 31-MAY-2011
 
-->
<!DOCTYPE boards [
<!ELEMENT boards (journal)+>
<!ELEMENT journal (titleISI , titleDBLP , isbn , publisher , if5years , researcher+)>
<!ELEMENT titleISI (#PCDATA)>
<!ELEMENT titleDBLP (#PCDATA)>
<!ELEMENT isbn (#PCDATA)>
<!ELEMENT if5years (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT researcher (#PCDATA)>
<!ATTLIST researcher sex (m | f | n) #REQUIRED>
<!ATTLIST researcher country CDATA #REQUIRED>
<!ATTLIST researcher level CDATA #REQUIRED>
]    >
<boards>
  <journal>
    <titleISI>Mis Quart</titleISI>
    <titleDBLP>MIS Quarterly</titleDBLP>
    <isbn>0276-7783</isbn>
    <publisher>U. Minnesota</publisher>
    <if5years> 9.208</if5years>
    <researcher sex="m" country="us" level="3">Detmar W. Straub</researcher>
    <researcher sex="f" country="sg" level="2">Soon Ang</researcher>
    <researcher sex="m" country="us" level="1">Youngjin Yoo</researcher>
  </journal>
 
  <journal>
    <titleISI>VLDB J</titleISI>
    <titleDBLP>VLDB J.</titleDBLP>
    <isbn>1066-8888</isbn>
    <publisher>Springer</publisher>
    <if5years> 6.987</if5years>
    <researcher sex="m" country="us" level="4">Philip A. Bernstein</researcher>
    <researcher sex="m" country="dk" level="4">Christian S. Jensen</researcher>
    <researcher sex="m" country="sg" level="4">Kian-Lee Tan</researcher>
  </journal>
 
  <journal>
    <titleISI>ACM T Inform Syst</titleISI>
    <titleDBLP>ACM Trans. Inf. Syst.</titleDBLP>
    <isbn>1046-8188</isbn>
    <publisher>ACM</publisher>
    <if5years> 5.774</if5years>
    <researcher sex="m" country="us" level="1">ChengXiang Zhai</researcher>
    <researcher sex="f" country="us" level="1">Yi Zhang</researcher>
    <researcher sex="m" country="au" level="1">Justin Zobel</researcher>
  </journal>
 
 
</boards>


Et mon code java simplifié correspondant au problème

inISI est un booléan me permettre de détecter quand est-ce que je suis dans l'élément à afficher. Si on dé-commente l'affichage c'est titleISI qui s'affiche, et je cherche donc à avoir le contenu de l'élément.
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
public void startElement(String uri, String localName, String qName,
			Attributes attributes) throws SAXException {
		...
		if(previoustitleISI.equals("journal")){
			//end elem
			nbJournal++;
 
			if(nbJournal>=2){
				firstJournal=true;
				inISI = true; 
		        element1Content = new StringBuffer();
				//System.out.println("titleISI: "+element1Content);
 
 
			}
Sauf que le soucis, c'est que le code suivant qui devrait ne m'afficher que le contenu de l'élément que je veux, m'affiche en réalité le fichier dans sa globalité !

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
public void characters(char[] ch, int start, int length)
			throws SAXException {
		if (inISI) {
	        element1Content.append(ch);
	        System.out.println("titleISI: "+element1Content);
	    }
		inISI=false;
	}
Merci pour votre aide.