Highlighted

XML parsing display question

Participant ,
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
Adobe Community Professional
Correct answer by BKBK | Adobe Community Professional

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.

Views

322

Likes

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

XML parsing display question

Participant ,
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
Adobe Community Professional
Correct answer by BKBK | Adobe Community Professional

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.

Views

323

Likes

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
Dec 27, 2015 0
Adobe Community Professional ,
Dec 30, 2015

Copy link to clipboard

Copied

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

should have value

'Miami Heat'

Likes

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
Reply
Loading...
Dec 30, 2015 0
Participant ,
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.

Likes

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
Reply
Loading...
Dec 30, 2015 0
Adobe Community Professional ,
Dec 30, 2015

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.

Likes

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
Reply
Loading...
Dec 30, 2015 0