开发者

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 insid开发者_如何转开发e 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.


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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜