Solved

AS3 does not recognize my XML...Error code #1034

Posted on 2008-10-04
2
738 Views
Last Modified: 2013-11-11
I am getting the following error code...does anyone know why the code that I am getting cannot be converted to XML?

I am downloading this DIRECTLY from eBay's API:

The Error returned by the script:
_______________________________
TypeError: Error #1034: Type Coercion failed: cannot convert "<?xml version="1.0" encoding="UTF-8"?>

  <FindItemsAdvancedResponse xmlns="urn:ebay:apis:eBLBaseComponents">
   <Timestamp>2008-10-05T01:28:51.821Z</Timestamp>
   <Ack>Success</Ack>
   <Build>e585_core_Bundled_7338347_R1</Build>
   <Version>585</Version>
   <SearchResult>
    <ItemArray>
     <Item>
      <ItemID>160288036936</ItemID>
      <EndTime>2008-10-05T22:57:17.000Z</EndTime>
      <ViewItemURLForNaturalSearch>http://cgi.ebay.com/Rapaport-Report-Diamond-Price-List-Guide-Save-Thousands_W0QQitemZ160288036936QQihZ006QQcategoryZ110739QQcmdZViewItem</ViewItemURLForNaturalSearch>
      <ListingType>Chinese</ListingType>
      <GalleryURL>http://thumbs2.ebaystatic.com/pict/1602880369368080_1.jpg</GalleryURL>
      <PrimaryCategoryID>110739</PrimaryCategoryID>
      <PrimaryCategoryName>Jewelry &amp; Watches:Loose Diamonds &amp; Gemstones:Diamonds (Natural):Round, Brilliant:1.50 to 1.99 carats</PrimaryCategoryName>
      <BidCount>1</BidCount>
      <ConvertedCurrentPrice currencyID="USD">0.99</ConvertedCurrentPrice>
      <ListingStatus>Active</ListingStatus>
      <TimeLeft>PT21H28M26S</TimeLeft>
      <Title>Rapaport Report Diamond Price List Guide Save Thousands</Title>
      <ShippingCostSummary>
       <ShippingServiceCost currencyID="USD">0.0</ShippingServiceCost>
       <ShippingType>Flat</ShippingType>
      </ShippingCostSummary>
     </Item>
    </ItemArray>
   </SearchResult>
   <PageNumber>1</PageNumber>
   <TotalPages>73</TotalPages>
   <TotalItems>722</TotalItems>
   <ItemSearchURL>http://jewelry.listings.ebay.com/_W0QQDemandDataZ1QQfsopZ32QQsacatZ10210QQsaprchiZ2Q2e0QQsaprcloZ0Q2e0QQsascsZ1QQsocmdZListingItemList</ItemSearchURL>
  </FindItemsAdvancedResponse>
 " to XML.
__________________________________

var myXML:XML = new XML();
var XML_URL:String = "http://some.api.ebay.com";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);
 
function xmlLoaded(event:Event):void {
    var myXML2:XML = myLoader.data;
    myXML = myXML2;
    trace("Data loaded."+myXML);
    trace("Each item is " + myXML..Item);
    trace("Item #2 is " + myXML..Item[1].ListingType);
}

Open in new window

0
Comment
Question by:sjamal_hsj
2 Comments
 
LVL 39

Expert Comment

by:blue-genie
ID: 22644674
the data returned is in a string format so try casting it

ie. myXML:XML = XML(loader.data);
0
 

Accepted Solution

by:
sjamal_hsj earned 0 total points
ID: 22654268
I tried that, it gives me a similar error.

However, I've solved it by removing the extra info at the beginning:

I've posted the code below for anyone who's iinterested.
var myXML1:String = myLoader.data;
myXML1 = myXML1.replace(' xmlns="urn:ebay:apis:eBLBaseComponents"', '');
myXML1 = myXML1.replace('<?xml version="1.0" encoding="UTF-8"?>', '');
myXML = XML(myXML1);

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question