[dom4j-user] XPath Problems

2003-01-11 Thread Joe
Hi, Firstly, how do you do an xpath search on just an element? Jenny Ynnej 1009 777 777 ... ... is the root element of the document. So lets say you have the element with id = "282" in an Element object, how do you perform an xpath *relatve to just that element*. p

RE: [dom4j-user] XPath Problems

2003-01-11 Thread Steen Lehmann
> Firstly, how do you do an xpath search on just an > element? > > > >Jenny >Ynnej >1009 >777 777 > > > ... > ... > If you want to search relative to the Element, just leave out the initial "/" (which means start with the document) and do something like: personE

Re: [dom4j-user] XPath Problems

2003-01-11 Thread David D. Lucas
First off, your xml is invalid, you should send us what you are actually using. But after fixing your example (some of the end tags have the "/" at the end instead of something like "") you should do the following: Element person=people.selectNodes("//Person[@id='282']"); Element firstName= pe

Re: [dom4j-user] XPath Problems

2003-01-11 Thread David D. Lucas
BTW, you will need to cast the selectNodes to an element. Element person=(Element)people.selectNodes("//Person[@id='282']"); Element firstName= person.element("FirstName"); -- ++ | David Lucasmailto:[EMAIL PRO

Re: [dom4j-user] XPath Problems

2003-01-11 Thread David D. Lucas
And it would be wrong to use Nodes (it returns a List), use Node to return only one. Element person=(Element)people.selectNode("//Person[@id='282']"); Element firstName= person.element("FirstName"); What a morning... -- ++ | David Lu