Accès à un noeud via XPath
Bonjour,
Je bloque sur une chose bête, quelque chose doit m'échapper mais je ne vois pas quoi. Je tente d'accéder à un noeud d'un document Xml via XPath mais je ne récupère que null.
Le fichier XML :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| <?xml version="1.0" encoding="UTF-8"?>
<schema xmlns:tns="http://www.example.org/Extension/"
xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/Extension/" xmlns:base="http://www.example.org/ExtendedSchema">
<import namespace="http://www.example.org/ExtendedSchema" schemaLocation="Default.xsd"></import>
<complexType name="Extension">
<complexContent>
<extension base="base:Default">
<sequence>
<element name="propertie1" type="boolean" maxOccurs="1" minOccurs="0"></element>
<element name="propertie2" type="string" maxOccurs="1" minOccurs="0"></element>
</sequence>
</extension>
</complexContent>
</complexType>
</schema> |
Et le code :
Code:
1 2 3 4
|
schema = new SAXReader().read(extension);
System.out.println(schema.selectSingleNode("/schema")); // "org.dom4j.tree.DefaultElement@6e1408 [Element: <schema uri..."
System.out.println(schema.selectSingleNode("/schema/complexType")); // "null" |
L'un d'entre vous sais t'il éclairer ma petite lanternne ? Merci
Edit : Par conter si je retire la namespace par defaut : "xmlns="http://www.w3.org/2001/XMLSchema" ça fonctionne très bien...