[JDOM] Accéder aux différentes nodes

Fermé
Seth - 30 mai 2008 à 09:42
 Seth - 30 mai 2008 à 11:03
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/TR/2002/REC-xmldsig-core-20020212/Overview.html"
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>
(...)
/CODE

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"));/CODE

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

1 réponse

J'ai trouvé, c'était un prob de namespace
0