tracker issue : CF-4203287

select a category, or use search below
(searches all categories and all time range)
Title:

[ANeff] Bug for: StructGet() doesn't support array notation when referencing an XML object

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Aaron Neff / ()

Created: 08/20/2018

Components: Language, XML

Versions: 2016,11.0,2018

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: 2018.0.0.310739 / 2020.0.0.314573

Priority/Frequency: Minor / Very few users will encounter

Locale/System: / Platforms All

Vote Count: 0

Issue: StructGet() doesn't support array notation when referencing an XML object

See blog: http://blog.cfaether.com/2018/08/coldfusion-member-functions-for-xml.html

-----------
Observation 9:
StructGet() does not support array notation when referencing an XML object. So, StructGet() needs fixed to support array notation when referencing an XML object. Repro: https://trycf.com/gist/baa6a4aeeec368e6567efe5cf827ee4c/acf2018?theme=monokai
-----------

Repro:

{code:java}
<cfxml variable="myXMLVar"><myXML><a b="c">d</a><a>e</a>f</myXML></cfxml>
<cfscript>
  myStruct1 = structGet("myXMLVar.myXML.a")
  try {
    myStruct2 = structGet("myXMLVar.myXML.a[1]")
  }
  catch(any e) {writeOutput(e.message)}
  writeDump(myXMLVar)
  writeDump(myStruct1)
  if(isDefined("myStruct2")) {
    writeDump(myStruct2)
  }
</cfscript>
{code}


Actual Result: Array notation in XML StructGet() throws "An error occurred while trying to add an XML node to an element."

Expected Result: Array notation in XML StructGet() works.

Related URL: https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-s/structget.html

Attachments:

Comments: