Finding XML files using xalan in Java

I need to write a java application that searches for keywords in tags and actual data from many XML files. From my research on the Internet, I get the feeling that I should use xalan, but I cannot figure out how to use it or what it does. Can someone point me in the right direction? Thanks

+3
source share
4 answers

The first thing you need to do is decide what data you are going to look for. You say “inside tags and actual data” - does this mean that you do a keyword search for the item name? Or the name of the element and its contents inside?

, , , , , Lucene. , , , , , .

, DOM XPath. , .

Xalan; JDK XML XPath. : (parsing), (xpath).

+2

Xalan XSLT: XSL, XML- - .

, XSL-, .

- XML, Lucene: . , XML Digester Lucene.

XPath. , .

+2

, XPath Java. XML- ( ). Xalan - , . Java, Java 5, XML XPath. Java XML-, , , , Java SDK.

. ( ) XPath, " ": http://www.ibm.com/developerworks/library/x-javaxpathapi.html

0

See this SO post on how to perform a search using the contains()XPath function .

Regarding an example on how to execute an XPath query, I suggest looking at the Java XPath documentation . Here is an example of the code they provide:

XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "/widgets/widget";
InputSource inputSource = new InputSource("widgets.xml");
NodeSet nodes = (NodeSet) xpath.evaluate(expression, inputSource, XPathConstants.NODESET);

This will load the file widgets.xmland return NodeSetall nodes matching the expression.

0
source

Source: https://habr.com/ru/post/1728740/


All Articles