次の XML があるとします。
<Contact>
<ContactID>41111-f15a-4fa1-b643-47877608f557</ContactID>
<ContactStatus>ACTIVE</ContactStatus>
<Name>ABC Ltd</Name>
<EmailAddress>xxx@xxx.co</EmailAddress>
<SkypeUserName>xxxdemo</SkypeUserName>
<Addresses>
<Address>
<AddressType>STREET</AddressType>
<AddressLine1>Radio XXX</AddressLine1>
<AddressLine2>4388 Ballarat Highway</AddressLine2>
<City>Melbourne</City>
<PostalCode>3133</PostalCode>
</Address>
<Address>
<AddressType>POBOX</AddressType>
<AddressLine1>Radio xx House</AddressLine1>
<AddressLine2>P O Box 1111</AddressLine2>
<City>Melbourne</City>
<Region>VIC</Region>
<PostalCode>3133</PostalCode>
</Address>
</Addresses>
<Phones>
<Phone>
<PhoneType>MOBILE</PhoneType>
</Phone>
<Phone>
<PhoneType>DEFAULT</PhoneType>
<PhoneNumber>1112222</PhoneNumber>
<PhoneAreaCode>03</PhoneAreaCode>
</Phone>
<Phone>
<PhoneType>FAX</PhoneType>
</Phone>
<Phone>
<PhoneType>DDI</PhoneType>
</Phone>
</Phones>
<UpdatedDateUTC>2012-07-26T20:06:00.75</UpdatedDateUTC>
<IsSupplier>false</IsSupplier>
<IsCustomer>true</IsCustomer>
</Contact>
<Contact>
Another contact...
</Contact>
次の方法で contactID にアクセスできます。
<cfset aContacts = XmlSearch(sResponse,"//Contact") />
<cfloop index="i" from="1" to="#arrayLen(aContacts)#">
<cfset sContactID = aContacts[i].ContactID>
</cfloop>
しかし、たとえば次のように、さまざまなアドレスの種類を解析するにはどうすればよいですか。
<cfloop index="i" from="1" to="#arrayLen(aContacts)#">
<cfset sContactID = aContacts[i].ContactID>
<cfset sStreetAddressLine1 = ??>
<cfset sStreetAddressLine2 = ??>
<cfset sStreetAddressCity = ??>
<cfset sStreetAddressPostalCode = ??>
<cfset sPOBoxAddressLine1 = ??>
<cfset sPOBoxAddressLine2 = ??>
<cfset sPOBoxAddressCity = ??>
<cfset sPOBoxAddressPostalCode = ??>
</cfloop>