newone2011
asked on
Exception in eval of XPATH API Try other way A location step was expected following the '/' or '//' token.
I am getting this error while calling the following code:
import java.io.File;
import javax.xml.parsers.Document BuilderFac tory;
import org.w3c.dom.Document;
public static void main(String[] args) {
String omxml =
"C:\\TestDir\testObj\TestF ile.xml";
File tfile = new File(omxml);
try {
doc = DocumentBuilderFactory.new Instance() .newDocume ntBuilder( ).parse(tf ile);
}catch(Exception eee){
eee.printStackTrace();
}
import java.io.File;
import javax.xml.parsers.Document
import org.w3c.dom.Document;
public static void main(String[] args) {
String omxml =
"C:\\TestDir\testObj\TestF
File tfile = new File(omxml);
try {
doc = DocumentBuilderFactory.new
}catch(Exception eee){
eee.printStackTrace();
}
Just from that code!? Can you possibly attach TestFile.xml to this q?
You should use \\ instead of one \
"C:\\TestDir\\testObj\\Tes tFile.xml" ;
You cannot use one backslash in the filepath in Java code as backshlash has a special meaning - in all cases you should use two backslashes
not only in the beginning
not only in the beginning
Missed that ;)
Much easier to do
"C:/TestDir/testObj/TestFi le.xml";
Much easier to do
"C:/TestDir/testObj/TestFi
No difference - "C:/TestDir/testObj/TestFi le.xml"; or this "C:\\TestDir\\testObj\\Tes tFile.xml" ;
With a single backslsh - this is a problem
With a single backslsh - this is a problem
ASKER
I am sorry, made a mistake while typing. It does have 2 backslashes, see below.
mport javax.xml.parsers.Document BuilderFac tory;
import org.w3c.dom.Document;
public static void main(String[] args) {
String omxml =
"C:\\TestDir\\testObj\\Tes tFile.xml" ; File tfile = new File(omxml);
try {
doc = DocumentBuilderFactory.new Instance() .newDocume ntBuilder( ).parse(tf ile);
}catch(Exception eee){
eee.printStackTrace();
}
The test file has following contents:
<?xml version="1.0" encoding="UTF-8"?>
<TestVOM>
<ApplicationConfig>
<TestWebServiceURL>http://www.test.com/Test.asmx</TestW ebServiceU RL>
</ApplicationConfig>
</TestVOM>
mport javax.xml.parsers.Document
import org.w3c.dom.Document;
public static void main(String[] args) {
String omxml =
"C:\\TestDir\\testObj\\Tes
try {
doc = DocumentBuilderFactory.new
}catch(Exception eee){
eee.printStackTrace();
}
The test file has following contents:
<?xml version="1.0" encoding="UTF-8"?>
<TestVOM>
<ApplicationConfig>
<TestWebServiceURL>http://www.test.com/Test.asmx</TestW
</ApplicationConfig>
</TestVOM>
So which line is throwing this execption - and can you post the stacktrace ?
and corresponding lines which are referreed in the stacktrace ?
and corresponding lines which are referreed in the stacktrace ?
ASKER
Its showing this in Tomcat logs:
Exception in eval of XPATH API Try other way A location step was expected following the '/' or '//' token
without any line no.
Just trying to make sure if it is being thrown elsewhere in a jar file code. Will update you. Thx
Exception in eval of XPATH API Try other way A location step was expected following the '/' or '//' token
without any line no.
Just trying to make sure if it is being thrown elsewhere in a jar file code. Will update you. Thx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, will do thx. Will let you know.
ASKER
Added points for effort