Question : Retrieve XMLAttribute in Coldfusion

Hello -

I'm unable to reach an xmlattribute with Coldfusion.

Here's the XML:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
<root>
	<Response>
		<FileID>948616</FileID>
		<FileDate>2010-07-09 10:47:00.421</FileDate>
		<FileContents>
			<PropertyInformation>
				<SiteList>
					<Site EntID="1053146" SiteID="1482584" PropNo="2650" SiteName="GRC" Adr1="7755 KG" Adr2="" City="CS" St="AL" Zip="12345" County="EP" Country="US" Phone1="(555) 555-5555" Phone2="" Fax="(555) 555-4100" Email="[email protected]" Web="www.grc.com" Long="" Lat="" PropDate="2010-07-08 00:00:00.000" SysDate="2010-07-09 10:46:36.960" AMEDate="2010-07-25 00:00:00.000" />
				</SiteList>
			</PropertyInformation>
		</FileContents>
	</Response>
</root>


And here is the .cfm page
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
<cfquery name="qryDELETE" datasource="#request.dsn#">
	DELETE FROM import_rp_file
</cfquery>

<cffile action="read" file="#xmluploadfolder#xmlimport.xml" variable="xmldoc">
<cfset mydoc = XmlParse(xmldoc)>

<!--- Create Variables to hold each section --->
<cfset FileID = xmlSearch(mydoc,'/root/Response/FileID')>
<cfset FileDate = xmlSearch(mydoc,'/root/Response/FileDate')>
<cfset Validation = xmlSearch(mydoc,'/root/Response/FileContents/PropertyInformation/Validation/Audit')>
<cfset SiteNow = xmlSearch(mydoc,'/root/Response/FileContents/PropertyInformation/SiteList/Site')>


<!--- Import File Info data --->
<cfset FileID = FileID[1].xmlText>
<cfset FileDate = FileDate[1].xmlText>


<cfquery name="qryInsertFileInfo" datasource="#request.dsn#">
    INSERT INTO import_rp_File
    (
        FileID,
        FileDate
    )
    VALUES
    (
        <cfqueryparam cfsqltype="cf_sql_varchar" value="#FileID#">,
        <cfqueryparam cfsqltype="cf_sql_dater" value="#FileDate#">
    )
</cfquery>


<cfoutput>
<cfloop from="1" to="#arraylen(SiteNow)#" index="i">
    #SiteNow[i].XMLAttribute['EntID']#
</cfloop>
</cfoutput>


I keep getting an error "Element XMLATTRIBUTE is undefined in a Java object of type class coldfusion.xml.XmlNodeMap."

Thanks in advance!

Answer : Retrieve XMLAttribute in Coldfusion

It's XMLAttributes (plural)

<cfdump var="#SiteNow[i].XmlAttributes['EntID']#">
Random Solutions  
 
programming4us programming4us