如何使用XML属性过滤XML节点?

时间:2018-03-30 11:04:09

标签: jquery xml

我想选择<NewsData> <NewsPhoto>女王[iType='Photo']" <NewsData> <NewsPhoto [iType='Photo']"></NewsPhoto> </NewsData> <NewsData> <NewsPhoto></NewsPhoto> </NewsData> <NewsData> <NewsPhoto [iType='Photo']"></NewsPhoto> </NewsData>...

  

XML

FilterItem

我使用Jquery过滤器,但 var FilterItem = $(xml).find('NewsData').filter(function(){ if($(this).children("NewsPhoto").attr('iType')=='Photo'){ return this; } }); console.log(FilterItem); 很难使用。

runtime: nodejs
env: flex

resources:
  cpu: 1
  memory_gb: 1
  disk_size_gb: 20

handlers:
- url: /api
  secure: always
  script: app.js

- url: /
  secure: always
  static_dir: public

enter image description here enter image description here 请给我一些建议!

1 个答案:

答案 0 :(得分:0)

试试这个,

$(xml).find("NewsData  NewsPhoto[iType='Photo']")