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

xml nodes that contain dashes

Explorer ,
Jul 13, 2007 Jul 13, 2007

Copy link to clipboard

Copied

so i am trying to pull content from an xml document that looks something like this:

<xts:sports-content-set>
<sports-content>
<sports-event>
<team>
</team>
</sports-event>
</sports/content>
</xts:sports-content-set>

and the problem i am having is that when i try to reference xmlroot.sports-content coldfusion throws an error that says sports is not a child element of xmlroot.
i think it is reading it as xmlroot.sports MINUS content.

how can i get around this so that it properly sees the child node as sports-content?

i tried xmlroot.xmlchildren['sports-content']

but that gave an error saying:
The value "sports-content" cannot be converted to a number

how can i reference this child node by name?

Views

397

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

Explorer , Jul 13, 2007 Jul 13, 2007
works like a charm thanks!

Votes

Translate

Translate
LEGEND ,
Jul 13, 2007 Jul 13, 2007

Copy link to clipboard

Copied

xmlroot.xmlchildren['sports-content']

You where on the right track, but xmlChildren is an array, not a
structure, you just need the bracket notation in your original form.

xmlroot["sports-content"]

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
Explorer ,
Jul 13, 2007 Jul 13, 2007

Copy link to clipboard

Copied

LATEST
works like a charm thanks!

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