Bonjour,
J'ai un fichier XML comme celui l�:
Et j'essaie d'atteindre les enfants de personName, j'ai essay� tout sorte de code dont :
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 <Candidate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ns.hr-xml.org/2004-08-02 Candidate.xsd" xmlns="http://ns.hr-xml.org/2004-08-02" xmlns:oa="http://www.openapplications.org/oagis" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xml:lang="en"> <CandidateProfile> <PersonalData> <PersonDescriptors> <BiologicalDescriptors> <DateOfBirth>1974-05-12</DateOfBirth> </BiologicalDescriptors> </PersonDescriptors> </PersonalData> </CandidateProfile> <Resume> <StructuredXMLResume> <ContactInfo> <PersonName> <GivenName>John</GivenName> <FamilyName>Glen</FamilyName> <Nationality>Français</Nationality> <relationship>Free lance</relationship> <DateStartIt> <Year>1980</Year> </DateStartIt> </PersonName> (...)
Mais il me dit que je pointe vers un �l�ment null, j'ai aussi essay� en mettant directement le GivenName sans les autres 'getChild()', mais cela ne fonctionne pas ... j'ai cherch� sur plusieurs tutoriels, mais pas moyen de trouver comment faire, je tourne en rond depuis plusieurs heures ...
Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
8
9
10
11 SAXBuilder sxb = new SAXBuilder(); try { document = sxb.build(new File("nomDuFichier.xml")); } catch(Exception e){} racine = document.getRootElement(); Element test = racine.getChild("Resume").getChild("StructuredXMLResume").getChild("ContactInfo").getChild("PersonName"); System.out.println(test.getChildText("GivenName"));
QUelqu'un aurait une id�e ?
D'avance merci !
Seth
Partager