删除xml中的某些重复元素

时间:2016-08-11 18:20:31

标签: java xml

我有一个xml,想要从xml文档中删除某些元素。最初我想删除这些元素中的控制字符,或者完全删除这些元素中的数据。

我的样本有效负载如下。我想删除简历/内容和评论。

<Jobs>
 <candidates>
   <address2/>
       <application>
          <comments>&lt;BR />Test emp1&#x0004;711 Newberg St. #4 Oregon, CA 97229   444-123-9752  testcandidate@gmail.com&#x0007;&#x0007;&lt;BR />authorName: Test 1 &#10; &#10;comment content: &lt;b>To: test test (test.test@yahoo.com)&lt;/b>&lt;br />&lt;br />From: abc Recruitment Team (test@abc.com)&lt;br />&lt;br />Subject: Tester at abc&lt;br />&lt;br />&lt;TEXTFORMAT LEADING="2">&lt;P ALIGN="LEFT">&lt;FONT FACE="Verdana" SIZE="12" COLOR="#353A3F" LETTERSPACING="0" KERNING="0">Hello test,&lt;/FONT>&lt;/P>&lt;/TEXTFORMAT>&lt;TEXTFORMAT LEADING="2">&lt;P ALIGN="LEFT">&lt;FONT FACE="Verdana" SIZE="12" COLOR="#353A3F" LETTERSPACING="0" KERNING="0">&lt;/FONT>&lt;/P>&lt;/TEXTFORMAT>&lt;TEXTFORMAT LEADING="2">&lt;P ALIGN="LEFT">&lt;FONT FACE="Verdana" SIZE="12" COLOR="#353A3F" LETTERSPACING="0" KERNING="0">Thank you for your interest in our abc opening. &lt;/FONT>&lt;/P></comments>
       <disposition>tesr Skills match</disposition>
       <eId>xyz</eId>
        <gender>Male</gender>
      <lastUpdatedDate>1340687163</lastUpdatedDate>
       <race>Undefined</race>
        <resume>
             <content>Test&lt;BR />Human Resources Manager / Business Partner &lt;BR />  portland, Oregon; 4454; &lt;BR /> Phone 020 444456;Mobile 088768999;E-mail test@yahoo.com &lt;BR /></content>
            <format>Text</format>
      </resume>
       <sentDate>1789993473</sentDate>
       <source>Linkedin</source>
       <sourceType>Import</sourceType>
       <veteranStatus>Undefined</veteranStatus>
       <workflowState>Offer Accepted</workflowState>
       <city>portland</city>
       <companyName/>
        <country>US</country>
        <eId>xyz</eId>
    </application>
 </candidates>
 <candidates>
   <address2/>
       <application>
            <comments>&lt;BR />Test emp2&#x0004;711 Newberg St. #4 Oregon, CA 97229 444-123-9752 testcandidate2@gmail.com&#x0007;&#x0007;&lt;BR />authorName: Test 2 &#10; &#10;</comments>
        <disposition>Skills match</disposition>
        <eId>xyz</eId>
        <gender>female</gender>
        <lastUpdatedDate>1340687163</lastUpdatedDate>
        <race>Undefined</race>
            <resume>
                 <content>Test&lt;BR />Program Manager / Business Partner       &lt;BR />  portland, Oregon; 4454; &lt;BR /> Phone 020 444456;Mobile 088768999;E-mail test@yahoo.com &lt;BR /></content>
             <format>Text</format>
        </resume>
         <sentDate>178444473</sentDate>
         <source>Linkedin</source>
         <sourceType>Import</sourceType>
        <veteranStatus>Undefined</veteranStatus>
        <workflowState>Offer Accepted</workflowState>
        <city>portland</city>
        <companyName/>
       <country>US</country>
       <eId>xyzabc</eId>`enter code here`
       </application>
    </candidates>
  </Jobs>

0 个答案:

没有答案