Quick Note: XmlAttributes

I have to use xml fairly often. Mostly for connecting to different web services. I haven't dealt with to many web services that return attributes within the XML like this:

<day d="0" t="Monday" dt="May 12">
<hi>73</hi>
<low>52</low>
<sunr>6:17 AM</sunr>
<suns>8:08 PM</suns>
<part p="d">
<icon>30</icon>
<t>Partly Cloudy</t>
<wind>
<s>17</s>
<gust>N/A</gust>
<d>291</d>
<t>WNW</t>
</wind>
<bt>P Cloudy</bt>
<ppcp>10</ppcp>
<hmid>39</hmid>
</part>
<part p="n">
<icon>31</icon>
<t>Clear</t>
<wind>
<s>16</s>
<gust>N/A</gust>
<d>337</d>
<t>NNW</t>
</wind>
<bt>Clear</bt>
<ppcp>10</ppcp>
<hmid>61</hmid>
</part>
</day>

I seem to always forget how to access the attributes. The attributes in above example are d="0" t="Monday" dt = "May 12" as well as p="d" and p = "n".

I have decided to blog about it so I remember next time.

To access the above attributes use XmlAttributes. If the variable containing the above XML was called XMLVar then you would use the following code to access the attributes:

Day of Week: #XMLVar.day.XmlAttributes.t#
Date: #XMLVar.d.XmlAttributes.dt#

Nothing to it really.

TrackBacks
There are no trackbacks for this entry.

Trackback URL for this entry:
http://www.cfedge.com/trackback.cfm?8326CC4E-60DB-BB56-3E70F5E337B5D3F9

Comments
BlogCFC was created by Raymond Camden. This blog is running version 5.7.