0

我有以下 xml,xmlApplicantActivityType:

<ApplicantActivityType>
  <Row codeName="ALL" codeDisplayName="- All activity type(s) - " selected="1"/>
  <Row codeName="REVGNMO" codeDisplayName="Reverse Give Notice" selected="0"/>
  <Row codeName="COLLECT" codeDisplayName="Collections" selected="0"/>
  <Row codeName="COMPLT" codeDisplayName="Complaint" selected="0"/>
  <Row codeName="DCOMT" codeDisplayName="Delinquency comments" selected="0"/>
  <Row codeName="GENNOTE" codeDisplayName="General note" selected="0"/>
  <Row codeName="PCOMT" codeDisplayName="Prepaid comments" selected="0"/>
  <Row codeName="SCRNOTE" codeDisplayName="Screening note" selected="0"/>
  <Row codeName="TFRSITE" codeDisplayName="Transferred to sister site" selected="0"/>
  <Row codeName="TFRUNIT" codeDisplayName="Transferred to new unit" selected="0"/>
</ApplicantActivityType>

现在我有一个条件,如果它是真的,带有 codeName="REVGNMO" 的行不应该出现/被删除。

if (x='Applicant')
{
//remove row with codeName="REVGNMO"
}

我如何用 javascript 做到这一点?

我所做的是以下内容,但出现错误:

var a = xmlApplicantActivityType.getElementsByTagName("ApplicantActivityType")[0];
var rows = a.childNodes;
    if(rows)
    {
        for(var i = 0; i < rows.length; i++)
        {
          var codeName = rows[i].getAttribute("codeName");


          if(codeName == "REVGNMO")
          {
          refnode = xmlApplicantActivityType.selectSingleNode("//ApplicantActivityType/Row[@codeName='REVGNMO']");

          xmlApplicantActivityType.selectSingleNode("//Row").removeChild(refnode);           
          }

         }
    }
4

1 回答 1

1
var a = xmlApplicantActivityTypeOnly.getElementsByTagName("ApplicantActivityType")[0];
        refnode = xmlApplicantActivityTypeOnly.selectSingleNode("//ApplicantActivityType/Row[@codeName='REVGNMO']");
        a.removeChild(refnode);
于 2013-11-05T07:49:22.553 回答