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

isDefined() xml array --> cfparam tag

Participant ,
Mar 02, 2007 Mar 02, 2007

Copy link to clipboard

Copied

OK, as many of us know you cannot use the isDefined() function on an array. Fine. So one of the agreed upon work arounds which I have seen may use is the cfparam tag as so:

<cfloop index="count" from="1" to="10">
<cfparam name="#house[count]#.rooms" default="" />
#house[count]#.rooms
</cfloop>

That's cool. Now, what is the deal with cfparam tag and it's use with xml?? Both of the following give me the error "An error occured while Parsing an XML document. Content is not allowed in prolog." What is that!??

First,
<cfloop index="count" from="1" to="10">
<cfparam name="#house[count]#.rooms.XmlText" default="" type="xml" />
#house[count]#.rooms.XmlText
</cfloop>

Second,
<cfloop index="count" from="1" to="10">
<cfparam name="#house[count]#.rooms.XmlText" default="<rooms></rooms>" type="xml" />
#house[count]#.rooms.XmlText
</cfloop>

TOPICS
Advanced techniques

Views

593

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 ,
Mar 02, 2007 Mar 02, 2007

Copy link to clipboard

Copied

"An error occured while Parsing an XML document. Content is not allowed
in prolog."


That means you are somehow creating illegal text before the XML prolog
which is the '<?xml version="1.0" encoding="utf-8"?>' line. This must
be the first line of a well formated XML document, nothing is allowed
before it.


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 ,
Mar 02, 2007 Mar 02, 2007

Copy link to clipboard

Copied

Thank Ian for the reply.

Going by what Ian stated, I need to find another means in which to determine if an xml array is defined or not, because the xml that I am parsing is being provided by a third party. Are there any suggestions, since currently isdefined(xml-array) doesn't work, and neither does <cfparam name="xml-array" default="" type="xml" />?

Help me, help me, pleeeease! lol.

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 ,
Mar 03, 2007 Mar 03, 2007

Copy link to clipboard

Copied

Won't using a CFTY/CFCATCH around the attempted access work to see if it is defined?

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
Advocate ,
Mar 05, 2007 Mar 05, 2007

Copy link to clipboard

Copied

LATEST
Since you are dealing with an array of structures, can you use the StructKeyExists() method to figure out if the element is present instead of using isDefined?

StructKeyExists(variables["#house[count]#.rooms"], "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
Resources
Documentation