[Simple-support] Finding element on several levels of an XML
Brought to you by:
niallg
|
From: Robert S. <rob...@gm...> - 2011-05-31 22:04:25
|
Hello,
Let's say I have the following XML structure:
<?xml version="1.0" encoding="UTF-8"?>
<ResC>
<ConRes>
<Err text="Error text 1" />
<ConList>
<Con>
<Err text="Error text 2" />
</Con>
</ConList>
</ConRes>
<Err text="Error text 3" />
</ResC>
I also have created the following class:
@Element(required=false)
public class Err {
@Attribut
private String text;
public String getText() { return text; }
public void setText(String text) { this.text = text; }
}
However I don't understand how I can "find" any or all <Err> elements in
the document. I'd like to avoid defining an Err object in ResC, ConRes
and Con as this element may appear on almost any level.
Using the XPath //Err[1] to get the very first <Err> does not work :-(
Could anybody help me with that?
Thanks,
Robert
|