Hi,

Firstly, how do you do an xpath search on just an
element?

<People>
 <Person id="282">
   <FirstName>Jenny<FirstName/>
   <LastName>Ynnej<LastName/>
   <Age>1009<Age/>
   <PhoneNumber>777 777 7777</PhoneNumber>
 </Person>
 <Person id="289">
 ...
 ...
</People>

<People/> is the root element of the document.
So lets say you have the <Person> element  with id =
"282" in an Element object, how do you perform an
xpath *relatve to just that element*.

personElement.selectNodes("/People/Person/FirstName")
works fine,
but
personElement.selectNodes("/Person/FirstName") does
not, so each xpath search is *still* performed on the
document as a whole, regardless if you perform it on a
sub element.

So how do you perform a *relative* search? The "//" is
not suitable here. Example: perhaps <PhoneNumber/>'s
element is 1 -> Infinity and you only want Jenny's
phone numbers and not every one in the entire
document.

And the second question is about namespaces and xpath.
How do you do a search when you don't know what the
xml namespace will be in the document, only the
structure. So it might be <cool:People/>,
<addressBook:People/> or whatever. Current xpath
requires you to include the namespace in the path,
"/cool:People/cool:Person/..." and so on. What would
be the best way to do this dynamically?

Regards,
Joe






__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to