XPath performance w/ Namespaces

Discussion in 'XML' started by Jim, Jan 29, 2004.

  1. Jim

    Jim Guest

    Hi,

    When using an XPath query on an XML document that contains namespaces,
    is there a more efficient way to find a node set based on the local
    name than

    //*[local-name()='MYNAME']

    Is there another syntax that avoids using a predicate?

    Thanks!

    Jim
     
    Jim, Jan 29, 2004
    #1
    1. Advertising

  2. Jim wrote:
    > Hi,
    >
    > When using an XPath query on an XML document that contains namespaces,
    > is there a more efficient way to find a node set based on the local
    > name than
    >
    > //*[local-name()='MYNAME']
    >
    > Is there another syntax that avoids using a predicate?


    Register a prefix for the namespace in your XPath engine (how this is
    done depends on the engine, have a look at the documentation) and use
    this namespace in the XPath.
    --
    Johannes Koch
    In te domine speravi; non confundar in aeternum.
    (Te Deum, 4th cent.)
     
    Johannes Koch, Jan 29, 2004
    #2
    1. Advertising

  3. In article <>,
    Jim <> wrote:

    >When using an XPath query on an XML document that contains namespaces,
    >is there a more efficient way to find a node set based on the local
    >name than
    >
    >//*[local-name()='MYNAME']
    >
    >Is there another syntax that avoids using a predicate?


    No, but do you really want to do it? Doing something to all elements
    with a certain local name regardless of their namespace seems like
    a hack to me.

    And I'd be surprised if the difference in efficiency is noticeable,
    though //*:MYNAME (if it were allowed) would certainly be more readable.

    -- Richard
    --
    Spam filter: to mail me from a .com/.net site, put my surname in the headers.

    FreeBSD rules!
     
    Richard Tobin, Jan 29, 2004
    #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. kj
    Replies:
    3
    Views:
    22,792
    sandhya
    Mar 27, 2010
  2. Stefan Franke

    XPath and namespaces...

    Stefan Franke, Jan 2, 2005, in forum: XML
    Replies:
    6
    Views:
    1,108
    Martin Honnen
    Jan 3, 2005
  3. Replies:
    1
    Views:
    506
    Romin
    Apr 20, 2005
  4. Omar
    Replies:
    4
    Views:
    18,618
    Patrick TJ McPhee
    Jun 21, 2005
  5. Piet
    Replies:
    2
    Views:
    490
Loading...

Share This Page