Hi,
We are using dom4j 1.6.1, to parse XML comming from somewhere. Sometime, the balise have mention of the namespace ( eg : ) and sometime not ( ). And it's make call of Element.selectSingleNode(String s ) fails.
For now we have 3 solutions, and we are not happy with them
1 - Remove all namespace occurence before doing anything with the xml document
xml = xml .replaceAll("xmlns=\"[^\"]*\"","");
xml = xml .replaceAll("ds:","");
xml = xml .replaceAll("etm:","");
[...] // and so on for each kind of namespace
2 - Remove namespace just before getting a node By calling
Element.remove(Namespace ns)
But it's works only for a node and the first level of child
3 - Clutter the code by
node = rootElement.selectSingleNode(NameWithoutNameSpace)
if ( node == null )
node = rootElement.selectSingleNode(NameWithNameSpace)
So ... what do you think ? Witch one is the less worse ? Have you other solution to propose ?