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

Help! I think i've found a very obvious bug?

Community Beginner ,
Jun 03, 2007 Jun 03, 2007

Copy link to clipboard

Copied

Hi all,

I've done a:

XmlParse(myitem)

I can't access any node using the following notation. The problem
seems to be the "-" in the node name. The error says it can't find todo, not todo-list.

#myxmldoc.todo-list.complete.XmlText#

If i try it with it written as todolist, it works. So I think the bug is you can't access xml notes with a "-" in the name??

Problem is I can't change the xml source. Any Ideas?

Many thanks,

Brett
TOPICS
Advanced techniques

Views

403

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

LEGEND , Jun 03, 2007 Jun 03, 2007
It's not a bug: it's bad syntax on your part.

There are explicitly stated rules about variable-naming in CF when using
dot notation. One gets around this by using array notation.

<cfxml variable="myxmldoc">
<todo-list>
<complete>foo</complete>
</todo-list>
</cfxml>

<cfoutput>
#myxmldoc["todo-list"].complete.xmlText#
</cfoutput>

--
Adam

Votes

Translate

Translate
LEGEND ,
Jun 03, 2007 Jun 03, 2007

Copy link to clipboard

Copied

It's not a bug: it's bad syntax on your part.

There are explicitly stated rules about variable-naming in CF when using
dot notation. One gets around this by using array notation.

<cfxml variable="myxmldoc">
<todo-list>
<complete>foo</complete>
</todo-list>
</cfxml>

<cfoutput>
#myxmldoc["todo-list"].complete.xmlText#
</cfoutput>

--
Adam

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 Beginner ,
Jun 04, 2007 Jun 04, 2007

Copy link to clipboard

Copied

Thank you.

So if I wanted to access a level deeper with that form of notation, do I do it like this?

#myXMLDocument["todo-lists"].["todo-item"].["my-var"].xmlText#

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 Beginner ,
Jun 04, 2007 Jun 04, 2007

Copy link to clipboard

Copied

worked it out its this:

#myXMLDocument["todo-lists"]["todo-item"]["my-var"][1].xmlText#

Many thanks Adam, I spent a few days trying to sort this one 8-(

8-)

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
LEGEND ,
Jun 04, 2007 Jun 04, 2007

Copy link to clipboard

Copied

LATEST
> Many thanks Adam, I spent a few days trying to sort this one 8-(

No worries. One clause of our "coding standard" is that a developer should
not dwell on any one problem for more than 30min before seeking help; be
that colleagues, docs, forums, google, etc. It's mayeb good general
advice.

--
Adam

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