JavaBits
JavaBits

Reputation: 2055

Searching XML through Java Codes

I have around 30 xml files with proper formatting and huge amount of data. I want to search these xml files for specific data retrival. Can you suggest any site or blog which i can use as aguideline to solve my problem.

I need to search inside of each tag for the keyword provided by the user. And also sometime the specific tag name which will return the content inside the tag according to the user request.

example : a.xml, b.xml, c.xml

inside a.xml 

<abc>
some content 
</abc>

User may search for abc the tag or some keyword inside the content. In both cases it should return the content or if more than one match then it should return the link for both by clicking which the user can see them one by one.

Upvotes: 0

Views: 944

Answers (3)

manolowar
manolowar

Reputation: 6982

I'd recommend using XPath, which is a SQL-like language for searching in XML documents

http://www.ibm.com/developerworks/library/x-javaxpathapi.html

Upvotes: 3

MarcoS
MarcoS

Reputation: 13574

You may store your XMLs into an XML database (for example eXist), and then query it using XQuery.

Upvotes: 2

Vincent Mimoun-Prat
Vincent Mimoun-Prat

Reputation: 28551

Use a SAX parser (no need to go back and forth within the documents plus huge amount of data hence don't use a DOM parser).

See this link for a tutorial.

Upvotes: 2

Related Questions