• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

XML parsing display question

Participant ,
Dec 27, 2015 Dec 27, 2015

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
XmlText 
XmlAttributes
struct
alias NBA
id 4353138d-4c22-4396-95d8-5f587d2df25c
name NBA
xmlns
daily-schedule
XmlText 
XmlAttributes
struct
date 2015-12-25
games
XmlText  
game
XmlText  
XmlAttributes
struct
away_team 583ecc9a-fb46-11e1-82cb-f4ce4684ea4c
coverage full
home_team 583ecea6-fb46-11e1-82cb-f4ce4684ea4c
id b55c5579-950b-4726-8d36-6467f6caa772
scheduled 2015-12-25T17:00:00+00:00
status scheduled
venue
XmlText
XmlAttributes
struct
address 601 Biscayne Blvd.
capacity 19600
city Miami
country USA
id b67d5f09-28b2-5bc6-9097-af312007d2f4
name American Airlines Arena
state FL
zip 33132
home
XmlText
XmlAttributes
struct
alias MIA
id 583ecea6-fb46-11e1-82cb-f4ce4684ea4c
name Miami Heat

Views

419

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 30, 2015 Dec 30, 2015

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.

Votes

Translate

Translate
Community Expert ,
Dec 30, 2015 Dec 30, 2015

Copy link to clipboard

Copied

mydoc.league.daily-schedule.games.game.home.xmlattributes.name

should have value

'Miami Heat'

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 30, 2015 Dec 30, 2015

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 30, 2015 Dec 30, 2015

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation