Evik James
Evik James

Reputation: 10473

How to get at an XML attribute and value in ColdFusion 8?

I am using ColdFusion 8.

I am trying to get at the BoothID attribute and value of the ExhibitorList. Here's my XML:

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

I am successfully able to get to anything I want except for the

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

}

How do I need to rephrase this to get at the BoothID attribute and value?

Upvotes: 2

Views: 6131

Answers (1)

Shawn Holmes
Shawn Holmes

Reputation: 3762

Replace your line that ends in // THE TROUBLE IS HERE with

BoothID = ResponseNodes[i].XmlAttributes.BoothID;

Upvotes: 6

Related Questions