Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
DOCTYPE in pubmed 5 43
XSLT Assistance 9 44
How can I assign SimpleXMLElements to variables? 5 29
C# SQL BULK INSERT CLASS 5 34
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to how to record live broadcast.

707 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

13 Experts available now in Live!

Get 1:1 Help Now