0

我有以下 XML,“gXML”从一个页面传递到另一个发送电子邮件的页面。

<root>
<Lease>
<Row resmid="10435" EmailAdd="none@nowhere.com" FirstName="Alex" LastName="Choobineh" leaid="6960" reshid="4203" OptInBit="1"/>
<Row resmid="10434" EmailAdd="none@nowhere.com" FirstName="Dan" LastName="Morseman" leaid="6960" reshid="4203" OptInBit="1"/>
<Row resmid="10440" EmailAdd="none@nowhere.com" FirstName="Belinda" LastName="Becerril" leaid="6968" reshid="4205" OptInBit="1"/>
<Row resmid="10456" EmailAdd="almigraso@gmail.com" FirstName="Danaedz" LastName="dupe" leaid="6968" reshid="4205" OptInBit="1"/>
</Lease>
</root>

我希望能够向每一行发送一封电子邮件。我希望它是这样的

for (each row){

blah blah blah (send email function)

}

我只是不确定如何在 xml 中选择行。你怎么做呢?

语言是javascript。

4

1 回答 1

1
function emailRowValues(xml) {
  var root = xml.getElementsByTagName("root")[0];
  if (root) {
    var lease = xml.getElementsByTagName("Lease")[0];
    var rows = lease.childNodes;
    if (rows) {
      for (var i = 0; i < rows.length; i++) {
        var resmid = rows[i].getAttribute("resmid");
        var EmailAdd = rows[i].getAttribute("EmailAdd");
        var FirstName = rows[i].getAttribute("FirstName");
        var LastName = rows[i].getAttribute("LastName");
        var leaid = rows[i].getAttribute("leaid");
        var reshid = rows[i].getAttribute("reshid");
        var OptInBit = rows[i].getAttribute("OptInBit");
    //send email function
      }
    }
  }
}
于 2012-10-18T09:54:45.843 回答