Lecture avec JDOM d'un string
bonjour,
je suis bloqué sur un point en XML avec la lecture par l API JDOM d un string XML
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Document documentLecture = null ;
Element racineLecture = null ;
/*debut de lecture de ce string */
SAXBuilder sax = new SAXBuilder();
try {
//on parse le string mais il y a un null pointer exception
documentLecture = sax.build(new String(ch));
}
catch(Exception e) {
}
racineLecture = documentLecture.getRootElement();
List widgetList = racineLecture.getChildren("widget");
Iterator i = widgetList.iterator();
while (i.hasNext()) {
Element courant = (Element) i.next();
System.out.println(courant.getChild("colonne_number").getText()+"(colonne_number)");
System.out.println(courant.getChild("colonne_value").getText()
+ "(colonne_value)");
} |
le string ressemble a ca
Code:
1 2 3 4 5 6 7
| <?xml version="1.0" encoding="UTF-8"?>
<form>
<widget>
<colonne_number>33</colonne_number>
<colonne_value>1000</colonne_value>
</widget>
</form> |
mais ca me retourne un nullpointeurException.
Apparement il retrouve pas le root. Est ce quelqu un peut m aider?