Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-10-04
2
Medium Priority
?
748 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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 last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
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 what frame rate is, how to control it and what effect it has on the video.

721 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