Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Reference to undeclared namespace prefix: 'soapenv'.

Reference to undeclared namespace prefix: 'soapenv'.

Reference to undeclared namespace prefix: 'soapenv'.

I am trying to get the following xpath expression to work:


I get the following error:
Unknown method.

I've often found that problems like this can be resolved by the following code (vbscript):


oRequest.setProperty "SelectionLanguage", "XPath"
oRequest is my xml document object.

After adding this, my xpath expression generates the following error:  Reference to undeclared namespace prefix: 'soapenv'.

Here is the first line of my xml source file:
<soapenv:Envelope xmlns:int="" xmlns:soapenv="" xmlns:xsi="">

Why does it not recognize soapenv as a valid name space?  If I don't include the line setting the language to xpath, it does not complain about the namespace.  It just does not recognize name() as a valid xpath function.

RE: Reference to undeclared namespace prefix: 'soapenv'.

Should take out the parentheses if name is an element node of no namespace qualification?

RE: Reference to undeclared namespace prefix: 'soapenv'.

Name is an xpath function.  It returns the name of the current node.

Here is the structure of my xml file:

<soapenv:Envelope xmlns:int="" xmlns:soapenv="" xmlns:xsi="">
    <ProcessUW xmlns="">

What I am trying to do is write an xpath expression that will return the name of the child node directly under <soapenv:Body>.  In this case, I would want the xpath expression to return 'ProcessUW'.  That is my soapMethod that I will be passing to a web service.

Here is a work around that I am currently using:


Set oXPathResult = oRequest.selectSingleNode("/soapenv:Envelope/soapenv:Body/*")
sSoapMethod = oXPathResult.nodeName
Can this be done with a single xpath expression instead of resorting to the DOM nodeName method?

RE: Reference to undeclared namespace prefix: 'soapenv'.


an xpath expression that will return the name of the child node directly under <soapenv:Body>
In other words, you want to fetch the method name.
That would be:


if you want the entire name (including namespace), or:


if you want just the element name without the namespace.  

Tom Morrison

RE: Reference to undeclared namespace prefix: 'soapenv'.



In other words, you want to fetch the method name.
Tom, thanks for stating it so concisely.  That is exactly what I am trying to do.  I tried your xpath expression:


I got the following error message:
Unknown method.


RE: Reference to undeclared namespace prefix: 'soapenv'.

I apologize for being unfamiliar with the procedural scripting language.  Perhaps tsuji will help with that.

name() and local-name() are XPath functions defined in the XPath specification, so I do not have any idea about what may be interpreting name() as a method.

Tom Morrison

RE: Reference to undeclared namespace prefix: 'soapenv'.

That error message is coming from microsofts xml parser, msxml.  It indicates that it does not recognize that name is a xpath function.  I've ran into this problem before, and the fix has always been to set the parser's language to "XPath".  Below is an excerpt from


Note: IE5 and later has implemented that [0] should be the first node, but according to the W3C standard it should have been [1]!!

A Workaround!
To solve the [0] and [1] problem in IE5+, you can set the SelectionLanguage to XPath.

The following example selects only the first book node under the bookstore element:

xmlDoc.setProperty "SelectionLanguage", "XPath"
Unfortunately, when I set the language "XPath" as in the example above, it complains about my undeclared namespace 'soapenv'.

RE: Reference to undeclared namespace prefix: 'soapenv'.

I think I understand what is causing your problem, and your workaround is probably the correct approach (i.e. not a workaround after all).

You are using the DOM.  The method selectNodes() expects an XPath expression that selects node(s).  But the XPath name() function does not return a nodeset, but rather a scalar value as a string.

Tom Morrison

RE: Reference to undeclared namespace prefix: 'soapenv'.

[1] When you want to return _directly_ the (quaified) name from the selectsinglenode method of DOMDocument, it is self contractory and bound to fail. The selectsinglenode method would always return object of type IDOMElement, never would it be a string, as q name.

[2] When you put setProperty on the SelectionLanguage (a "second-level" dom property) to XPath, you have to be more rigorous in the namespace. You've to setProperty of the SelectionNamespaces as well. (Setting these is a version-dependent thing of msxml2 core service.) Like this.

oRequest.setProperty "SelectionLanguage", "XPath"
oRequest.setProperty "SelectioNamespaces", "xmlns:soapenv=""

(If there are more namespaces, just add to the value with space seperator.

RE: Reference to undeclared namespace prefix: 'soapenv'.

Still some error slipped in there. A re-take!
    oRequest.setProperty "SelectionNamespaces", "xmlns:soapenv=''"

RE: Reference to undeclared namespace prefix: 'soapenv'.


Thanks so much for clearing everything up.  I had assumed I could use the name function with XML DOM because it works fine in my xslt files, but I now understand why that won't work.  Also thanks for showing me how to get around the undefined namespace error when setting the selectionLanguage to 'XPath'.

- Dan  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close