Copy link to clipboard
Copied
I'm clearly not understanding how to parse my XML file. I can get the first "child" but I don't know how to get children after that.
To get the league name I use the below code which was pulled from a cffile which retrieved the XML doc and that works fine:
<cfdump var="#mydoc#">
#mydoc.league.xmlattributes.name# = NBA
In the below, what would be the code to get the "home" team "name"?
Cheers!
My XML:
xml document [short version] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
league |
|
The dash may have something to do with it. As an alternative, use the associative-array style:
mydoc.league["daily-schedule"].games.game.home.xmlattributes.name
In any case, keep to the XML best practice when naming your elements.
Copy link to clipboard
Copied
mydoc.league.daily-schedule.games.game.home.xmlattributes.name
should have value
'Miami Heat'
Copy link to clipboard
Copied
I get the following error:
Element LEAGUE.DAILY is undefined in MYDOC. <br>The error occurred on line 33.
Do you think the dash in daily-schedule is the issue?
Thanks!
B.
Copy link to clipboard
Copied
The dash may have something to do with it. As an alternative, use the associative-array style:
mydoc.league["daily-schedule"].games.game.home.xmlattributes.name
In any case, keep to the XML best practice when naming your elements.