XPath showing NULL value.Please help.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • luthriaajay
    New Member
    • Apr 2007
    • 56

    #1

    XPath showing NULL value.Please help.

    Why is my xpath giving null for the the flwg

    Code:
    <Configuration>
    <Listener.Whiteboard>
    		<AQListener>
    			<Product>A</Product>
    			<Message.Class>XMLMessage</Message.Class>
    			<Database>
    			    <URL></URL>
    			</Database>
    		</AQListener>
    </Listener.Whiteboard>
    </Configuration>
    	
    
    
    Java Code:
    ---------
    
    1) wbCL.initialise(m_config.getNode("/Configuration/Listener.Whiteboard"));
    
    2) private void initialise(Node confignode){
    
       XPath xpath = XPathFactory.newInstance().newXPath();
       Node listenerconfignode = (Node)xpath.evaluate("AQListener",confignode, XPathConstants.NODE);
      
       }
    Why is the listernerconfig node being set to NULL?
    Am i missing something?
  • dorinbogdan
    Recognized Expert Contributor
    • Feb 2007
    • 839

    #2
    Check if confignode is null, it may be incorrectly set.
    Eventually try to use document node instead of confignode, and build the xpath as "Configurat ion/Listener.Whiteb oard/AQListener"

    Comment

    • luthriaajay
      New Member
      • Apr 2007
      • 56

      #3
      The confignode is correctly set as when I say:

      Code:
      String szproduct = xpath.evaluate("AQListener/Product/text()", confignode);
      System.out.println("szproduct  " + szproduct);
      
      Output: EQ.D

      Comment

      • luthriaajay
        New Member
        • Apr 2007
        • 56

        #4
        Product : A and (not EQ.D) my mistake

        Comment

        Working...