commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anton Stoyanov <anton.stoya...@gmail.com>
Subject JXPath xml file loading
Date Tue, 15 Feb 2005 03:43:38 GMT
Hi guys, 

probably the easiest of things, but I can't get it to work , can you
help me please (the example from the manual)



import org.apache.commons.jxpath.JXPathContext;
import java.net.URL;
import org.apache.commons.jxpath.Container;
import org.apache.commons.jxpath.xml.DocumentContainer;



public class test {
    
    public static void main(String[] args) {
        JXPathContext  context = JXPathContext.newContext(new Address());
        String street = (String)context.getValue( "address/street");
    }
}

class Address {
    private Container locations = null;

    public Container getLocations(){
        if (locations == null){
            URL url = getClass().getResource("address.xml");
            locations = new DocumentContainer(url);
        }
        return locations;
    }
 }



with and address.xml of just:

<?xml version="1.0" ?>
<address>
<street>test</street>
</address>



gives me an error : 
org.apache.commons.jxpath.JXPathException: No value for xpath: address/street
	at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getValue(JXPathContextReferenceImpl.java:344)
	at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getValue(JXPathContextReferenceImpl.java:280)
	at test.main(test.java:26)
Exception in thread "main" 




any ideas ? 

thanks alot.



-- 
----------------------
Anton Stoyanov

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message