This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes XPATH in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XPATH in Java" Watch "XPATH in Java" New topic
Author

XPATH in Java

Prabha Dhandapani
Ranch Hand

Joined: Sep 11, 2003
Posts: 70
Hello everybody,
I have an XML document stored in the database as CLOB.I need to query the document for data inside specific tags.I want to use XPATH for this.I read about XPATH.But I want to know how it can be used in a Java Program inside WSAD.Would appreciate if somebody can direct me to a sample source code that reads the XML document and extracts specific element data.Also,please let me know if there is any API that I can use...Any help ASAP would be great.
Many Thanks,
Prabha
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Are you expecting to write an XPath expression then use
that with a Java program and query the Db to get some value
out of the XML file.........


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Prabha Dhandapani
Ranch Hand

Joined: Sep 11, 2003
Posts: 70
Hi Madhav,
Thanks for the reply.Actually, I have the XML file stored as a column in a table.I need to extract the file from the table which is fine.After extracting it,do i need to parse the XML file to use XPath???If that is the case, then I can parse it using DOM or SAX Parser...Once I parse it,how do I implement XPATH in the program to say get the valus of the "price" for the below xml???Please let me know if there are any examples for doing this. Also, do I need to parse the XML always to use XPATH or is there a way where I can use the XML direcly without parsing because I know parsing sometimes throws exception based on the XML File...
<book price="100">
</book>
Thanks,
Prabha
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
You seem to be thinking correctly as far as getting the file from the
DB and then understanding the requirement to parse it.
Now for the part where you want the answer to getting the value
based on the XPath, I am kinda hazy on that...I myself am trying
to follow these tutorials for DOM/SAX trying to learn things.
Hopefully someone else has a better (direct) answer to your question.
regds.
- m
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XPATH in Java
 
Similar Threads
reading xml file in Android
Resolving namespace when using xpath
Resolving namespace using xpath
create xml document by xpath in java
CDATA in html