Bonjour,
J'ai un fichier XML comme celui là:
Code :
- <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>
- (...)
|
Et j'essaie d'atteindre les enfants de personName, j'ai essayé tout sorte de code dont :
Code :
- 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" ));
|
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 ...
QUelqu'un aurait une idée ?
D'avance merci !
Seth