# TypeError: Error #1034: Type Coercion failed: cannot convert XMLList@59dc17f1 to XML

**URL:** <https://forum.kirupa.com/t/typeerror-error-1034-type-coercion-failed-cannot-convert-xmllist-59dc17f1-to-xml/280342>\
**Category:** Uncategorized\
**Created:** [January 26, 2009, 3:38pm UTC](https://forum.kirupa.com/t/typeerror-error-1034-type-coercion-failed-cannot-convert-xmllist-59dc17f1-to-xml/280342 "2009-01-26T15:38:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![IanCremona](https://avatars.discourse-cdn.com/v4/letter/i/65b543/32.png) [@IanCremona](https://forum.kirupa.com/u/IanCremona)\
**Post date:** [January 26, 2009, 3:38pm UTC](https://forum.kirupa.com/t/typeerror-error-1034-type-coercion-failed-cannot-convert-xmllist-59dc17f1-to-xml/280342/1 "2009-01-26T15:38:00Z")

</div>

Why does the trace work, and the statement does not? (please see code comments)

```auto

import fl.controls.*;

var info_txt:TextArea = panel_mc.main_mc.info_txt;

var gallery_xml:XML;
var xmlReq:URLRequest = new URLRequest("dataevents.xml");
var xmlLoader:URLLoader = new URLLoader();

function xmlLoaded(event:Event):void
{
    var query:XML;
    var queryText:String = "";
    gallery_xml = new XML(xmlLoader.data);
    
    query = (gallery_xml..profile.(profilename == "Sebastian Homann")); // This gives error TypeError: Error #1034: Type Coercion failed: cannot convert XMLList@59dc27f1 to XML.
    
    trace(gallery_xml..profile.(profilename == "Sebastian Homann")); /// This works
    
    for each(var elements:XML in query.*)
    {
        if(elements.*.length() <= 1)
        {
            queryText += elements.name() + ": " + elements + "
";
        }
        else
        {
            for each(var info:XML in elements.*)
            {
                queryText += info.name() + ": " + info + "
";
            }
        }
    }
    queryText += "file: " + query.@file;

    info_txt.htmlText = queryText;
}

xmlLoader.load(xmlReq);
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

```

Full error:

TypeError: Error #1034: Type Coercion failed: cannot convert XMLList@59dc17f1 to XML.  
at 06\_Looping\_XML\_Final\_fla::MainTimeline/xmlLoaded()  
at flash.events::EventDispatcher/dispatchEventFunction()  
at flash.events::EventDispatcher/dispatchEvent()  
at [flash.net](http://flash.net)::URLLoader/onComplete()
