wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes How to go for  XPATH 2.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to go for  XPATH 2.0" Watch "How to go for  XPATH 2.0" New topic
Author

How to go for XPATH 2.0

Anish Kuti
Greenhorn

Joined: May 12, 2008
Posts: 29
Hi All,
I am using JDK1.5 and java XML parser (import javax.xml.*) for parsing my XML.Now while I am using
count(distinct-values(//tag/items/itemid)) ,my parser is getting failed. later I came to know this above type of XPATH is only supported by XPATH 2.0.

Can anyone let me know What I have to do to make my parser enable to parse the above type of xpath (supporting XPATH 2.0) ? Any change in code or any jar to be used!!

I am using the below java code to parse my XML
----------------------------------------
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
import org.xml.sax.InputSource;



public class XmlParsing {

public void get() throws Throwable
{
String aa ="count(distinct-values(//tag/items/itemid))";
InputSource is = new InputSource("C://Users//kanis//Documents//office//Support//SMI_CHM6544.xml");
XPath xpath = XPathFactory.newInstance().newXPath();
String strArbitaryinfo= (String) xpath.evaluate(aa, is, XPathConstants.STRING);
System.out.println("------------------------Xml String ------------------\n"+strArbitaryinfo+"\n-----------------------------------------------------");


}
public static void main(String[] args) throws Throwable {
new XmlParsing().get();
}
}
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41108
    
  45
Saxon (http://saxon.sourceforge.net/) implements XPath 2.0.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to go for XPATH 2.0
 
Similar Threads
Storing of Data
startElement not called, why not?
How to detect EOF when using java.io.BufferedReader?
An exception in java-XML --kindly clarify-urgent
XPath and Modified DOM document object...