Javascript 使用jquery检索xml命名空间子元素值
伙计们 我是jquery新手,在这里我查阅了很多关于使用jquery解析namespace formatting.xml的帖子。在浏览了我的代码并查看了示例之后,我正在努力从嵌套的子元素中获取一个值。下面是我的xml代码片段:Javascript 使用jquery检索xml命名空间子元素值,javascript,jquery,xml,namespaces,Javascript,Jquery,Xml,Namespaces,伙计们 我是jquery新手,在这里我查阅了很多关于使用jquery解析namespace formatting.xml的帖子。在浏览了我的代码并查看了示例之后,我正在努力从嵌套的子元素中获取一个值。下面是我的xml代码片段: <offers:offer-bundle> <cash:offer lang="EN" offer-type="Cash"> <cash:cash> <cash:cannot-be-combined-with></ca
<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>
我的控制台窗口打印出一个蓝色的小圆圈,里面有数字2,还有“hereexecuting”,没有值。即使我使用
$(this).find('cash\:免责声明,免责声明')。每个(函数(i,v){})与$offer.find('cash\:免责声明,免责声明')。每个(函数(i,v){
我在控制台窗口中得到了相同的结果。任何想法或知识共享都将不胜感激。看起来像是Try
.find([nodeName=cash:offer]”)的副本。
嘿,本,谢谢你看我的问题。我读了那篇文章,尝试了$(this)。find(['nodeName=“cash:disclaimer”])。text();我仍然没有得到任何价值。仍然在研究,看看谁遇到过类似的情况。我有一个大脑放屁……:(解决了我的问题!!!谢谢大家。。。。。。
$(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() );