Solved

Select XML node with Namespaces using Classic ASP

Posted on 2013-10-22
2
917 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 500 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Html fieldset fix its height and width 4 44
Wordpress Cron - Send XML Data to external server FTP 3 34
send email part1 9 41
MS SQL and column defined as time 7 28
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

697 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