Hi Bob

From: "bob mcwhirter" <[EMAIL PROTECTED]>
> On Wed, 11 Jul 2001, James Strachan wrote:
>
> > From: "bob mcwhirter" <[EMAIL PROTECTED]>
> > > > Hi,
> > > > What is the XPath query for the name of the first child element?
> > >
> > > Probably something like this:
> > >
> > > local-name(/.)
> > > namespace-uri(/.)
> >
> > Choose either name() or local-name() depending on if your document uses
> > namespace prefixes then use either:-
> >
> > name(/*)
> > name(node())
> >
> > These both work.
> >
> > I'm not sure name(/.) is a valid path.
>
> /. is a short-hand abbreviated xpath for /self::node(),
> which is what you presented.

Sorry Bob - I must have had a bad-email day yesterday, my email was rubbish.
I'll try that again...

To get the name of the first element you can use...

name(/*)
name(/child::node())

However the following expressions

/.
/self::node()

refer (AFAIK) to the document node, not the first child node (the root
element). So the following expressions would return a blank string, since
name() of a document is empty according to the XPath spec.

name(/.) or name(/self::node())

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to