Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to write xpath to extract ALL text under an element

843834Feb 15 2008 — edited Feb 15 2008
Hi, I need to extract every contents (text contents and not tags) under some tag, which may contain further tags, and I wonder how I can achieve this? For example suppose my xml looks like
<doc>
<title> The title of this message is (<italic> Question about xpath </italic> )</title>
</doc>
And I want to extract the "title", which should be "The title of this message is (Question about xpath)".

My xpath query is
//doc/title/text()
which only gives me "The title of this message is ()" and the "italic" contents are missing.

Is there anyway to revise this query to extract every contents under the "title" tag?

Thank you !
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 14 2008
Added on Feb 15 2008
2 comments
298 views