Can you query from a non-root node using XPathAPI?

Discussion in 'XML' started by Scott Simpson, Jun 9, 2005.

  1. Can you query from a non-root node using XPathAPI's function
    selectNodeList(Node contextNode, java.lang.String str)? I'm trying this
    using the XPath expression "//*" and I'm getting nothing back. I know the
    node I pass to this function has data in it because I'm inspecting it in the
    debugger using Eclipse. The Javadoc doesn't say you can't query from a
    non-root node. Thanks.
     
    Scott Simpson, Jun 9, 2005
    #1
    1. Advertising

  2. Scott Simpson wrote:

    > Can you query from a non-root node using XPathAPI's function
    > selectNodeList(Node contextNode, java.lang.String str)? I'm trying this
    > using the XPath expression "//*" and I'm getting nothing back. I know the
    > node I pass to this function has data in it because I'm inspecting it in the
    > debugger using Eclipse. The Javadoc doesn't say you can't query from a
    > non-root node. Thanks.


    //* is an absolute path, it is never relative but always goes down from
    the document root node to all element nodes in the document.
    If you want a relative path you are probably looking for
    .//*
    which goes down from the context node to all element descendant nodes.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jun 10, 2005
    #2
    1. Advertising

  3. Thank you. That worked.

    "Martin Honnen" <> wrote in message
    news:42a9768d$0$24362$-online.net...
    >
    >
    > Scott Simpson wrote:
    >
    >> Can you query from a non-root node using XPathAPI's function
    >> selectNodeList(Node contextNode, java.lang.String str)? I'm trying this
    >> using the XPath expression "//*" and I'm getting nothing back. I know the
    >> node I pass to this function has data in it because I'm inspecting it in
    >> the debugger using Eclipse. The Javadoc doesn't say you can't query from
    >> a non-root node. Thanks.

    >
    > //* is an absolute path, it is never relative but always goes down from
    > the document root node to all element nodes in the document.
    > If you want a relative path you are probably looking for
    > .//*
    > which goes down from the context node to all element descendant nodes.
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/
     
    Scott Simpson, Jun 10, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve W. Jackson

    Re: XPathAPI: a query that returns an int ?

    Steve W. Jackson, Jul 17, 2003, in forum: Java
    Replies:
    2
    Views:
    480
    Steve W. Jackson
    Jul 18, 2003
  2. asd
    Replies:
    3
    Views:
    642
  3. Replies:
    1
    Views:
    506
    Martin Honnen
    May 17, 2005
  4. Tjerk Wolterink
    Replies:
    2
    Views:
    1,506
    Dimitre Novatchev
    Aug 24, 2006
  5. David  Portabella
    Replies:
    2
    Views:
    600
    David Portabella
    Aug 27, 2007
Loading...

Share This Page