[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Select XML node with Namespaces using Classic ASP

Posted on 2013-10-22
2
Medium Priority
?
996 Views
Last Modified: 2013-10-23
I have an XML file that uses namespaces. I need to access these nodes using classic ASP. I've done this before on a different XML file that did not use namespaces using something like:

For Each wNode In xmlDoc2.SelectNodes("/inv-balance/item") 

Open in new window


Apparently, that won't work this time since the XML uses namespaces.

Here is the XML file I'm working with. How do I access the nodes using classic ASP and namespaces?

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getInventoryQtyTransitDaysResponse xmlns:ns2="http://impl.webservice.integration.sanmar.com/">
<return>
<errorOccurred>false</errorOccurred>
<listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance">
<style>ST350</style>
<color>Iron Grey</color>
<size>XS</size>
<inventoryKey></inventoryKey>
<sizeIndex></sizeIndex>
<shipToPostalCode>99202</shipToPostalCode>
<quantity>69</quantity>
<daysInTransit>1</daysInTransit>
</listResponse>


<listResponse xsi:type="ns2:item" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance">
<style>ST350</style>
<color>Iron Grey</color>
<size>S</size> 
<inventoryKey></inventoryKey>
<sizeIndex></sizeIndex>
<shipToPostalCode>99202</shipToPostalCode>
<quantity>500</quantity>
<daysInTransit>1</daysInTransit>
</listResponse>



<message>Request fulfilled successfully</message>
</return>
</ns2:getInventoryQtyTransitDaysResponse>
</S:Body>
</S:Envelope>

Open in new window


My ASP code so far:

set xmlDoc2 = createObject("MSXML2.DOMDocument")
xmlDoc2.async = False
xmlDoc2.setProperty "ServerHTTPRequest", true
xmlDoc2.load("http://www.sportsupplygroup.com/Sanmar/transit.xml")
For Each oNode In xmlDoc2.SelectNodes(?????)

Open in new window

0
Comment
Question by:P-Daddy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:P-Daddy
ID: 39592454
I need to access the size node.
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 39593589
first note that (//size) will work since <size> is NOT in a namespace
(there is no default namespace declared)

for the nodes inside namespaces, you need to bind a namespace prefix

(assuming the selectionLanguage is set to XPath:

xmlDoc2.setProperty "SelectionNamespaces", "xmlns:foo='http://impl.webservice.integration.sanmar.com/'"

will allow you to select the nodes //foo:getInventoryQtyTransitDaysResponse

note that I changed the prefix on purpos, it is not the prefix that is important, but the namespace uri it is bound to
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question