Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XPath performance w/ Namespaces

Reply
Thread Tools

XPath performance w/ Namespaces

 
 
Jim
Guest
Posts: n/a
 
      01-29-2004
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
 
Reply With Quote
 
 
 
 
Johannes Koch
Guest
Posts: n/a
 
      01-29-2004
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.)
 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      01-29-2004
In article <(E-Mail Removed) >,
Jim <(E-Mail Removed)> 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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XPath: selecting on namespaces kj XML 3 03-27-2010 10:23 AM
XPath and namespaces : a newbie question Omar XML 4 06-21-2005 04:41 AM
XPath expressions having namespaces gimme_this_gimme_that@yahoo.com XML 1 04-20-2005 05:03 AM
Error on xpath-ing a DOM with namespaces Piet Python 2 03-09-2005 08:23 PM
XPath and namespaces... Stefan Franke XML 6 01-03-2005 06:55 PM



Advertisments