D
Doug Miller
I can't seem to get this reply parsed correctly. All I'm really interested in
are Package.Postage.MailService and Package.Postage.Rate. Code snippet
follows.
<?xml version="1.0" ?>
<RateV3Response>
<Package ID="1">
<ZipOrigination>46228</ZipOrigination>
<ZipDestination>62522</ZipDestination>
<Pounds>3</Pounds>
<Ounces>0</Ounces>
<Size>REGULAR</Size>
<Zone>3</Zone>
<Postage CLASSID="1">
<MailService>Priority Mail</MailService>
<Rate>5.70</Rate>
</Postage>
</Package>
</RateV3Response>
I'm encountering *no* problems sending the request, or receiving the reply --
or displaying the *entire* reply. It's getting at the individual fields that
I'm having trouble with.
Here's the relevant portion of the code. Somebody please show me what I'm
doing wrong (or failing to do, as the case may be).
TIA...
var package = new Array;
package = objSrvHTTP.responseXML.getElementsByTagName("Package");
alert (package.length);
// displays 0 !! What's going on? Should be 1, shouldn't it?
alert (package.firstChild.nodeValue);
// complains that the object doesn't support this property or method
for (var i = 0; i < package.length; i++) {
// since package.length = 0, obviously the loop will do nothing
var pkg = package.item(i);
var postage = pkg.getElementsByTagName("Postage");
for (var j = 0; j < postage.length; j++) {
var pstg = postage.item(j);
var rate = pstg.getElementsByTagName("Rate");
var srvc = pstg.getElementsByTagName("MailService");
Service.innerText = srvc.item(0).firstChild.nodeValue;
Rate.innerText = rate.item(0).firstChild.nodeValue;
}
}
are Package.Postage.MailService and Package.Postage.Rate. Code snippet
follows.
<?xml version="1.0" ?>
<RateV3Response>
<Package ID="1">
<ZipOrigination>46228</ZipOrigination>
<ZipDestination>62522</ZipDestination>
<Pounds>3</Pounds>
<Ounces>0</Ounces>
<Size>REGULAR</Size>
<Zone>3</Zone>
<Postage CLASSID="1">
<MailService>Priority Mail</MailService>
<Rate>5.70</Rate>
</Postage>
</Package>
</RateV3Response>
I'm encountering *no* problems sending the request, or receiving the reply --
or displaying the *entire* reply. It's getting at the individual fields that
I'm having trouble with.
Here's the relevant portion of the code. Somebody please show me what I'm
doing wrong (or failing to do, as the case may be).
TIA...
var package = new Array;
package = objSrvHTTP.responseXML.getElementsByTagName("Package");
alert (package.length);
// displays 0 !! What's going on? Should be 1, shouldn't it?
alert (package.firstChild.nodeValue);
// complains that the object doesn't support this property or method
for (var i = 0; i < package.length; i++) {
// since package.length = 0, obviously the loop will do nothing
var pkg = package.item(i);
var postage = pkg.getElementsByTagName("Postage");
for (var j = 0; j < postage.length; j++) {
var pstg = postage.item(j);
var rate = pstg.getElementsByTagName("Rate");
var srvc = pstg.getElementsByTagName("MailService");
Service.innerText = srvc.item(0).firstChild.nodeValue;
Rate.innerText = rate.item(0).firstChild.nodeValue;
}
}