Folks.
I am new to jquery and I checked out alot of the postings here when it comes to parsing namespace formatting .xml using jquery. After going over my code and looking at the examples I am struggling grabbing a value from a nested child element. Below is my xml snippet:
<offers:offer-bundle>
<cash:offer lang="EN" offer-type="Cash">
<cash:cash>
<cash:cannot-be-combined-with></cash:cannot-be-combined-with>
<cash:cash-amount>1000</cash:cash-amount>
<cash:requires-tfs-financing>false</cash:requires-tfs-financing>
<cash:stackable-with-apr>false</cash:stackable-with-apr>
<cash:stackable-with-lease>false</cash:stackable-with-lease>
<cash:sub-type-labels>Cash Back</cash:sub-type-labels>
</cash:cash>
<cash:tfs-calculator>false</cash:tfs-calculator>
<cash:offer-label>Cash Back</cash:offer-label>
<cash:offer-label-num>7</cash:offer-label-num>
<cash:series-list></cash:series-list>
<cash:offer-id>cash_1433205220095</cash:offer-id>
<cash:start-date>2015-06-02</cash:start-date>
<cash:end-date>2015-07-06</cash:end-date>
<cash:title>2015 Cash Back Offer</cash:title>
<cash:use-for-email>false</cash:use-for-email>
<cash:description>I can get this value</cash:description>
<cash:offer-image/>
<cash:offer-image-alt/>
<cash:offer-image-disclaimer/>
<cash:offer-card>...</cash:offer-card>
<cash:bullets>...</cash:bullets>
<cash:disclaimers>
<cash:disclaimer>
**I NEED TO GET THIS CHILD ELEMENT VALUE.**
</cash:disclaimer>
</cash:disclaimers>
</offers:offer-bundle>
I am able to get the value of <cash:offer-card>
, <cash:offer-id
> etc. since it does not have any nested children. I am struggling with getting the child node of <cash:disclaimers>
.
Here is what I've written so far:
$.ajax({ type : "GET", url : webServiceURL, dataType : "xml", success : function (xml) {
$(xml).find('offers\\:offer-bundle, offer-bundle').each(function(index, value) {
var $incentive;
var $offer;
var $offerDescription;
var $offerDisclaimer;
//Do Cash: Condition code is executing, incentive is hard coded to 'cash'
if (incentive == 'cash') {
$incentive = $(this);
$offer = $incentive.find('cash\\:offer, offer');
$offerDescription = $offer.find('cash\\:description, description').text();
$offer.find('cash\\:disclaimers, disclaimers').each(function (i, v) {
console.log ("here executing" + $(i).find('cash\\:disclaimer, disclaimer').text() );
My console window prints out a blue little circle with the number 2 in it along with "here executing" and no value. Even if I use
$(this).find('cash\:disclaimers, disclaimers').each(function (i, v) { }) versus $offer.find('cash\:disclaimers, disclaimers').each(function (i, v) {
I get the same results in my console window. Any ideas or knowledge sharing would be greatly appreciate it.