B
Ben
I have a web service that returns the following xml:
<?xml version="1.0" encoding="utf-8" ?>
<NewDataSet>
<Addresses>
<XML_F52E2B61-18A1-11d1-B105-00805F49916B>
<CustomerAddressBase
CustomerAddressId="259DA89E-3B3F-DB11-90EA-0016353D15C7"
AddrName="PRIMARY" />
<CustomerAddressBase
CustomerAddressId="269DA89E-3B3F-DB11-90EA-0016353D15C7" />
<CustomerAddressBase
CustomerAddressId="9778EE83-3B70-DB11-B20C-0016353D15C7" AddrName="test
address" />
</XML_F52E2B61-18A1-11d1-B105-00805F49916B>
</Addresses>
</NewDataSet>
I want to loop through each CustomerAddressBase tag and pull out the
CustomerAddressId and AddrName. I can use getElementsByTagName on tag
XML_F52E2B61-18A1-11d1-B105-00805F49916B with no problems, but when I
try to use it to pull CustomerAddressBase I get an empty set and no
length. Here's the code I've been using to test this:
// Instantiate at connection to the Web service and call the get
method.
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var objXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
// crmForm.all.salutation.DataValue =
"http://bert:5555/webservices/clientaddress.asmx/SRReturnAddr?AccountGUID="
+ s
xmlhttp.open("get",
"http://bert:5555/webservices/clientaddress.asmx/SRReturnAddr?AccountGUID="
+ s, false);
xmlhttp.send();
//crmForm.all.emailaddress1.DataValue = xmlhttp.responseText;
objXmlDoc.loadXML(xmlhttp.responseText);
//var noOfCustomerAddressTags =
objXmlDoc.getElementsByTagName("XML_F52E2B61-18A1-11d1-B105-00805F49916B").length;
var xmltag=
objXmlDoc.getElementsByTagName("XML_F52E2B61-18A1-11d1-B105-00805F49916B");
var CustomerAddressTags=
xmltag[0].getElementsByTagName("CustomerAddressBase");
var noOfCustomerAddressTags =
xmltag[0].getElementsByTagName("CustomerAddressBase").length;
crmForm.all.emailaddress1.DataValue =
CustomerAddressTags[0].firstChild.nodeValue;
for (var x = 0; x < noOfCustomerAddressTags; x++)
{
crmForm.all.emailaddress1.DataValue = "test";
}
Does anyone have any idea why I can't pull the CustomerAddressBase?
I've tried it using
objXmlDoc.getElementsByTagName("CustomerAddressBase") with no luck as
well. Thanks in advance.
Ben
<?xml version="1.0" encoding="utf-8" ?>
<NewDataSet>
<Addresses>
<XML_F52E2B61-18A1-11d1-B105-00805F49916B>
<CustomerAddressBase
CustomerAddressId="259DA89E-3B3F-DB11-90EA-0016353D15C7"
AddrName="PRIMARY" />
<CustomerAddressBase
CustomerAddressId="269DA89E-3B3F-DB11-90EA-0016353D15C7" />
<CustomerAddressBase
CustomerAddressId="9778EE83-3B70-DB11-B20C-0016353D15C7" AddrName="test
address" />
</XML_F52E2B61-18A1-11d1-B105-00805F49916B>
</Addresses>
</NewDataSet>
I want to loop through each CustomerAddressBase tag and pull out the
CustomerAddressId and AddrName. I can use getElementsByTagName on tag
XML_F52E2B61-18A1-11d1-B105-00805F49916B with no problems, but when I
try to use it to pull CustomerAddressBase I get an empty set and no
length. Here's the code I've been using to test this:
// Instantiate at connection to the Web service and call the get
method.
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var objXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
// crmForm.all.salutation.DataValue =
"http://bert:5555/webservices/clientaddress.asmx/SRReturnAddr?AccountGUID="
+ s
xmlhttp.open("get",
"http://bert:5555/webservices/clientaddress.asmx/SRReturnAddr?AccountGUID="
+ s, false);
xmlhttp.send();
//crmForm.all.emailaddress1.DataValue = xmlhttp.responseText;
objXmlDoc.loadXML(xmlhttp.responseText);
//var noOfCustomerAddressTags =
objXmlDoc.getElementsByTagName("XML_F52E2B61-18A1-11d1-B105-00805F49916B").length;
var xmltag=
objXmlDoc.getElementsByTagName("XML_F52E2B61-18A1-11d1-B105-00805F49916B");
var CustomerAddressTags=
xmltag[0].getElementsByTagName("CustomerAddressBase");
var noOfCustomerAddressTags =
xmltag[0].getElementsByTagName("CustomerAddressBase").length;
crmForm.all.emailaddress1.DataValue =
CustomerAddressTags[0].firstChild.nodeValue;
for (var x = 0; x < noOfCustomerAddressTags; x++)
{
crmForm.all.emailaddress1.DataValue = "test";
}
Does anyone have any idea why I can't pull the CustomerAddressBase?
I've tried it using
objXmlDoc.getElementsByTagName("CustomerAddressBase") with no luck as
well. Thanks in advance.
Ben