Well it's an HTML document. It does have an xmlns declaration, although
it's been a while since I've done any XML so I don't remember exactly
what that does. But the elements themselves, like <meta> don't have any
namespace prefixed to them.

 

The xmlns declaration is:

 

<html xmlns="http://www.w3.org/1999/xhtml"; lang="fr">

 

Thanks for your help

 

________________________________

From: Linus Kamb [mailto:li...@iris.washington.edu] 
Sent: jeudi 16 avril 2009 17:29
To: Rossner, Matt PH/FR/PREST
Subject: Re: [dom4j-user] xpath problem

 

namespace?

matt.rossner-pr...@sanofi-aventis.com wrote: 

Hello,

 

I'm having an issue with a very simple Xpath expression. I don't quite
understand why this fails. Probably missing something obvious. This is
just a simple example:

 

SAXReader r = new SAXReader();

        try {

            Document document = r.read(new File("c:\\file.xml"));

            

            Element metaEle = (Element)
document.selectSingleNode("//meta");

            

        } catch (Exception e) {

            e.printStackTrace();

        }

 

Now < file.xml > definitely has a meta element but this always returns
null. I've tried also selectNodes to see if that makes any difference. I
tried with a bunch of other tags but they all fail unless if I put in
the root tag. If I'm not mistaken though "//meta" should return all meta
elements in the document??? Thanks for any help with this.

 

Matt

 

 

 

 



________________________________



 
------------------------------------------------------------------------
------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
 



________________________________



 
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user
  
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to