Hi Folks,
I am encountering what I think is a simple problem but I haven't been able to solve it. I am trying to parse a simple XML file and I keep getting the following exception...
Exception in thread "main" javax.xml.transform.TransformerException: A location step was expected following the '/' or '//' token.
at com.sun.org.apache.xpath.internal.compiler.XPathParser.error(Unknown Source)
... more lines ...
Caused by: javax.xml.transform.TransformerException: A location step was expected following the '/' or '//' token.
at com.sun.org.apache.xpath.internal.compiler.XPathParser.error(Unknown Source)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.RelativeLocationPath(Unknown Source)
at com.sun.org.apache.xpath.internal.compiler.XPathParser.LocationPath(Unknown Source)
I am convinced the problem is that the file isn't being found so the parser returns the exception above. I have built my documentBuilder and XPath objects correctly. Here is the code that I am using...
//Create builder and xpath objects
DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = dbfactory.newDocumentBuilder();
XPathFactory xpfactory = XPathFactory.newInstance();
XPath path = xpfactory.newXPath();
//Find the XML file and start parsing
String fName = "C:\\Bank.xml"; // Windows path
File f = new File(fName);
Document doc = builder.parse(f); // Parsing
I've tried various adjustments to get the parser to find the file, including simply specifyng the filename by itself (no specific path). I am using Eclipse and included the file in the project so I thought it would be found there without a problem but I guess not. In any case, nothing I've tried has worked. Can anyone kindly offer any suggestions?
Any help is greatly appreciated!
Thanks and have a great weekend!
Tyster