Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSXML Undeclared Namespace error

Status
Not open for further replies.

Miquella

Programmer
Mar 11, 2005
41
US
I'm trying to get MSXML to parse an encoded SOAP response we're getting from a Web Services interface. (MSVC++)

When I get the response back, and pass it into the MSXML parser, it parses fine, but then when I try to query a node out of it, it throws an error saying that the encoding namespace (declared as xmlns:enc=" I forget the URI, it's on my other computer here...) is undeclared, does anyone have any idea why this would be? Or how I could move forward trying to figure it out.

I suspect that it can't resolve the URI's, because I don't have them in my XMLSchemaCache, but I don't have a way of knowing what URI's they'll be sending back in their response. I thought that this is what the ResolveExternals property was for, but maybe I'm completely off in left field here...

Thank you tremendously for your help! I've been beating my head against the wall for the past day and a half!

-Miquella
 
Let oparser be the reference to the parser in question.
[tt] oparser.setProperty "SelectionNamespaces", "xmlns:enc='[/tt]
Actually, the prefix string is free and it has no need to be in accordance with what appears in the source document. Whereas, the uri has to be in agreement.
 
Thank you for your response. I was able to find this same thing out last night, but didn't get a chance to come back until just now.

But another question: how do I know what namespaces the document uses? The documents that I'm loading can have different namespaces everytime I load them.

The way that I got it to work is a little ugly, but it works:

I loop through every root node <?xml?> && <root />, processing every attribute for each, looking to see if it begins with "xmlns:", then I recurse through all of the children element nodes, checking the same things, and just building them all into a space delimited string as I go, and setProperty("SelectionNamespaces", namespacesStr).

Is there any better way of doing this??

-Thanks again,
Miquella
 
If you work with msxml2 in vb(s), then you can check out namespace axis like this.
[tt]
oparser.setproperty "SelectionLanguage","XPath"
set cns=oparser.selectnodes("namespace::*")
s=""
for each ons in cns
s=s & ons.name & vbtab & ons.nodevalue & vbcrlf
next
'display s for your study
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top