I know a variant of this question has come up
before, but I couldn't find it in a search of the archives. Assume I have
a file structured something like this:
<doc xmlns:xx="urlxx" xmlns:dc="urlyyy"
xmlns="urlns">
<title>My Book</title>
<date>My Date</date>
<dc:author>My
Author</dc:author>
</doc>
If I convert it to a DOM, I can operate on it
easily:
String title =
doc.elementText("title");
String date = doc.elementText("date");
However, when I get to the author element, the only
way I can make work is:
String author =
doc.selectSingleNode("*[local-name() = 'author']").getText();
Isn't there a more straightforward and robust way
to get element values when a namespace happens to be involved?
I have a feeling this is a really dumb question
with a *really* simple answer, but I'm stuck, so
here it is.
Terry
|
- Re: [dom4j-user] XPath Namespace Question Terry Steichen
- Re: [dom4j-user] XPath Namespace Question David D. Lucas