Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now