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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

showing all nodes 1

Status
Not open for further replies.

schase

Technical User
Sep 7, 2001
1,756
US
Howdy,

I do not know if this should be here or in the ASP forum. But I'm trying to get USPS's API to gather shipping rates. I can send the request and get the response ok - except I'm stuck on two things.

How do I look for the node name of error in place of package?

And second - if I do a write out of the response back, the first set shows correctly. This is what i'm using to just write it out - except there are suppose to be two lines instead of just the first.


Code:
Set mydoc=Server.CreateObject("Microsoft.xmlDOM") 
mydoc.loadxml(responsexml) 
Set NodeList = mydoc.documentElement.selectNodes("Package") 
For strCount = 0 To NodeList.length - 1 
response.write NodeList.Item(strCount).selectSingleNode("Postage/MailService").Text & " - $ " & NodeList.Item(strCount).selectSingleNode("Postage/Rate").Text & "<BR>"
NEXT

That code will spit out one line like this

Code:
Priority Mail Flat Rate Box (11.25" x 8.75" x 6") - $ 7.70

instead of both lines as shown in the XML itself below.


This is how usps returns the data in it's entirity - all I need is the mailservice and rate that are inside the Postage Nodes. I never request more than one Package ID at a time.

Code:
  <?xml version="1.0" ?> 
- <RateV2Response>
- <Package ID="0">
  <ZipOrigination>10022</ZipOrigination> 
  <ZipDestination>20008</ZipDestination> 
  <Pounds>10</Pounds> 
  <Ounces>5</Ounces> 
  <Container>Flat Rate Box</Container> 
  <Size>REGULAR</Size> 
  <Zone>3</Zone> 
- <Postage>
  <MailService>Priority Mail Flat Rate Box (11.25" x 8.75" x 6")</MailService> 
  <Rate>7.70</Rate> 
  </Postage>
- <Postage>
  <MailService>Priority Mail Flat Rate Box (14" x 12" x 3.5")</MailService> 
  <Rate>7.70</Rate> 
  </Postage>
  </Package>
  </RateV2Response>

I am very weak on XML, trying mostly to modify code I got to work for UPS to show USPS okay. Thank you for your help in advance.


Stuart
A+, Net+, Security+, MCP
 
It would seem to me that there is only one Package node, so you should expect only one line. Why do expect more than one line per package?

Tom Morrison
 
no I know there is only one Package - as that's all I ever pull for.

but there are multiple Postage nodes - thats the part I need is all of them instead of just the first one.


Stuart
A+, Net+, Security+, MCP
 
[tt]
Set mydoc=Server.CreateObject("Microsoft.xmlDOM")
mydoc.loadxml responsexml
Set NodeList = mydoc.documentElement.selectNodes("Package/Postage")
For strCount = 0 To NodeList.length - 1
response.write NodeList.Item(strCount).selectSingleNode("MailService").Text & " - $ " & NodeList.Item(strCount).selectSingleNode("Rate").Text & "<BR>"
NEXT
[/tt]
 
perfect!

I had tried about every combination I could think of - except that one.

Many thanks.


Stuart
A+, Net+, Security+, MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top