• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 345
  • Last Modified:

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.DocumentBuilderFactory;

import org.w3c.dom.Document;
public static void main(String[] args) {
            String omxml =
                  "C:\\TestDir\testObj\TestFile.xml";      
            File tfile = new File(omxml);
            
            try {
                   doc  = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(tfile);
                  }catch(Exception eee){
                    eee.printStackTrace();
                  }
0
newone2011
Asked:
newone2011
  • 6
  • 4
  • 2
1 Solution
 
CEHJCommented:
Just from that code!? Can you possibly attach TestFile.xml to this q?
0
 
for_yanCommented:

You should use \\ instead of one \
0
 
for_yanCommented:
  "C:\\TestDir\\testObj\\TestFile.xml";      
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
for_yanCommented:
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
0
 
CEHJCommented:
Missed that ;)

Much easier to do

 "C:/TestDir/testObj/TestFile.xml";      
0
 
for_yanCommented:
No difference -  "C:/TestDir/testObj/TestFile.xml";       or this  "C:\\TestDir\\testObj\\TestFile.xml";      
With a single backslsh - this is a problem
0
 
newone2011Author Commented:
I am sorry, made a mistake while typing. It does have 2 backslashes, see below.
mport javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
public static void main(String[] args) {
            String omxml =
                 "C:\\TestDir\\testObj\\TestFile.xml";                  File tfile = new File(omxml);
           
            try {
                   doc  = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(tfile);
                  }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</TestWebServiceURL>
</ApplicationConfig>
</TestVOM>
0
 
for_yanCommented:
So which line is throwing this execption - and can you post the stacktrace ?
and corresponding lines which are referreed in the stacktrace ?
0
 
newone2011Author Commented:
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
0
 
for_yanCommented:

look for some xPath.evaluate comand in the code - something looking like this one:

list = (NodeList) xPath.evaluate("(//ns:sessionUID)|(//ns:eNewSTok)",  source, XPathConstants.NODESET);

Open in new window

0
 
newone2011Author Commented:
Ok, will do thx. Will let you know.
0
 
newone2011Author Commented:
Added points for effort
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now