如何在ColdFusion 8中获取XML属性和值?

时间:2012-03-07 22:57:58

标签: xml coldfusion

我正在使用ColdFusion 8。

我正在尝试获取ExhibitorList的BoothID属性和值。这是我的XML:

<ExhibitorList BoothID="164991">
    <BoothNumber>N1849</BoothNumber>
    <CompanyID>407</CompanyID>
    <CompanyNumber>166212</CompanyNumber>
</ExhibitorList>

除了

之外,我成功地得到了我想要的任何东西
SoapResponse = xmlParse(httpResponse.fileContent);
ResponseNodes = xmlSearch(SoapResponse, "//*[ local-name() = 'ExhibitorList' ]");
for (i = 1; i lte arrayLen(ResponseNodes); i++) {
    BoothNumber = ResponseNodes[i].BoothNumber;
    CompanyID = ResponseNodes[i].CompanyID;
    CompanyNumber= ResponseNodes[i].CompanyNumber;

    BoothID = xmlSearch(ResponseNodes[i], "@BoothID");  // THE TROUBLE IS HERE

}

如何更改这一点以获取BoothID属性和值?

1 个答案:

答案 0 :(得分:6)

替换以// 结尾的行

BoothID = ResponseNodes[i].XmlAttributes.BoothID;