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

Problems with variable names with dashes

Guest
Feb 11, 2007 Feb 11, 2007
I am trying to retrieve data from an XML file where some of the Element names contain a dash (-). If I try the following:

<cfset numItems = ArrayLen(mydoc.us-patent-grant.us-bibliographic-data-grant.references-cited.citation.XmlChildren)>

I get the error:
Element US is undefined in MYDOC.

I suspect that the '-' is causing the problems since if I change the element names so that they do not contain a dash my code works. Is there a code that I can use instead of dash? I am not creating the XML files so I cannot change its format.

Thanks for the help.
1.1K
Translate
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 ,
Feb 11, 2007 Feb 11, 2007
<cfset numItems = ArrayLen(mydoc["us-patent-grant.us-bibliographic-data-grant"]["references-cited"].citation.XmlChildren)>
Translate
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
Guest
Feb 11, 2007 Feb 11, 2007
Thanks for the quick reply.

I tried it and now I get the following error:

Element us-patent-grant.us-bibliographic-data-grant is undefined in a Java object of type class coldfusion.xml.XmlNodeList referenced as

(I am new to XML and coldfusion)
Translate
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
Guest
Feb 12, 2007 Feb 12, 2007
Anyone else have any suggestions? I could use the help.
Thanks
Translate
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
Guest
Feb 12, 2007 Feb 12, 2007
Joe's suggestion was right, he just missed a period.

You should use:

<cfset numItems = ArrayLen (mydoc["us-patent-grant"]["us-bibliographic-data-grant"]["references-cited"].citation.XmlChildren)>


Do you see the pattern?
Translate
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
Guest
Feb 12, 2007 Feb 12, 2007
Thank you! That was it.
Translate
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
Guest
Feb 12, 2007 Feb 12, 2007
LATEST
Thanks again
Translate
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