Solved

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

Posted on 2008-10-04
2
739 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

830 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