Because the nsm element is in the "network:config:nsm" namespace, you need to specify that in your XPath. Something like this:
XPath xpath = new JDOMXPath("/network/service[@id='bumble']/n:nsm/n:filter/n:max_size"); SimpleNamespaceContext nsContext = new SimpleNamespaceContext(); nsContext.addNamespace( "n","network:config:nsm"); xpath.setNamespaceContext(nsContext); The prefix can be anything you want - and it obviously doesn't have to be the same prefix as in the original document - but it does have to be there. If an element is namespaced, even if it is the default namespace, XPath requires that it be declared and prefixed. David ----- Original Message ----- From: "Mark Cantrell" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Saturday, November 16, 2002 12:30 AM Subject: [Jaxen] xpath expression for jdom > Hello, > I'm using jdom with jaxen and have a bit of xml which doesn't return any > nodes when I apply an xpath statement > > here's the bit of xml > <network> > <service id="bumble"> > <host>localhost</host> > <nsm xmlns="network:config:nsm"> > <filter> > <default/> > <max_size>100</max_size> > </filter> > </nsm> > </service> > </network> > > here's the faulty xpath expression > "/network/service[@id='bumble']/nsm/filter/max_size" > > I would have expected this would return '100', however there is nothing. > I'm not sure if it's my bad xpath or xml, or if there is something else > going on with the xmlns namespace attribute. > > please advice > --mark > > > > -- > 6F56 FEF3 75AC 4507 3AB9 9DCE 5432 08C6 5557 C1E8 > ---------------------------------------------------- > | gpg --keyserver pgp.mit.edu --recv-keys 5557C1E8 | > ---------------------------------------------------- > > > > ------------------------------------------------------- > This sf.net email is sponsored by: To learn the basics of securing > your web site with SSL, click here to get a FREE TRIAL of a Thawte > Server Certificate: http://www.gothawte.com/rd524.html > _______________________________________________ > Jaxen-interest mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/jaxen-interest ------------------------------------------------------- This sf.net email is sponsored by: To learn the basics of securing your web site with SSL, click here to get a FREE TRIAL of a Thawte Server Certificate: http://www.gothawte.com/rd524.html _______________________________________________ Jaxen-interest mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jaxen-interest