0

I have my XML file like below

<atom:entry>
  <atom:id>Alex Kane</atom:id>
  <atom:title type="text/html">Alex Kane</atom:title>
  <atom:author>
    <atom:uri>uid=wpsadmin,o=defaultWIMFileBasedRealm</atom:uri>
    <atom:name>uid=wpsadmin,o=defaultWIMFileBasedRealm</atom:name>
  </atom:author>       
  <wplc:field id="imagepath">/wps/wcm/connect/4a2dffd8-bf49-47f0-8b9a-5e842f6fa63b/Kane_Alex_whitecoat_191x288.png?MOD=AJPERES
    <![CDATA[&amp;CACHEID=4a2dffd8-bf49-47f0-8b9a-5e842f6fa63b]]>
  </wplc:field>
  <wplc:field id="gender">MALE</wplc:field>
  <wplc:field id="doc_source">default</wplc:field>
  <wplc:field id="degree">M.D.</wplc:field>
  <wplc:field id="defaultcontext">/poc</wplc:field>
  <wplc:field id="contentsourcetype">Seedlist</wplc:field>
  <wplc:field id="contentSourceType">Seedlist</wplc:field>       
  <wplc:field id="docid">Alex Kane</wplc:field>
  <wplc:field id="title">Alex Kane</wplc:field>
  <wplc:field id="language">English</wplc:field>
  <wplc:field id="doctortype">Plastic Surgery</wplc:field>
  <wplc:field id="condition">3D Surface Motion Capture</wplc:field>
  <wplc:field id="condition">3D Surface Scan</wplc:field>
  <wplc:field id="condition">Kinematic Motion Capture</wplc:field>       
  <wplc:field id="security_ids">Z6QReDeIPO2JIT62BDIJM8CKHDAJMG6P1P2MM8C3BEIJMK61BPAMPCCG1CIJP8623</wplc:field>
  <wplc:field id="type">Specialist</wplc:field>
  <wplc:field id="description">Plastic Surgery</wplc:field>
  <wplc:field id="contentPath">/Blog Solo Template v70/Blog/Home/95c189804d4268bf8d49ede9170f1e3d</wplc:field>
</atom:entry>

Like above I have hundreds of atom:entry tags are there in my xml file. Here what I need to do is loop through each and every atom entry tag and check whether a specific child tag is exists or not. Like check if there is wplc:field id="type" exists or not.

If the specific node doesn't exist ignore remaining atom entry parent node and get only that parent node which doesn't have that specific child node.

How should I achieve this?

Ilanus
  • 6,690
  • 5
  • 13
  • 37
Vamshi
  • 186
  • 4
  • 16

1 Answers1

0

You can parse the xml using jquery and then use filter function to get the nodes that do not have element type as id in it:

$('atom\\:entry').filter(function(){
 return $(this).find('#type').length == 0 ;
})

Working Demo

enter image description here

Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125