2010-06-29 70 views
1

我想加載一些XML到閃存來填充一些動態文本字段。我遇到的問題是一些xml標籤似乎被flash忽略。actionscript 3加載xml不加載一些標籤

下面是我在加載XML:

<?xml version="1.0" encoding="UTF-8" ?><xml> 
    <node> 
    <nid>2</nid> 
    <name>Antonia O&#039;Neill</name> 
    <jobtitle>Director</jobtitle> 
    <photo>http://202.58.37.93/dev.mapandpage.com.au/backend/sites/default/files/MAP-holder.jpg</photo> 
    <bio>&lt;p&gt;Antonia formed Map and Page in 2007 as an independent subsidiary of Macquarie Radio Network. In her role as Director she oversees corporate affairs and community relations for Macquarie Radio Network (2GB + 2CH), the Australian Jockey Club, John Singleton, Harvey Norman, Magic Millions, National Rugby League, and Maserati.&lt;/p&gt; 

&lt;p&gt; Her expertise in the full spectrum of communications; both corporate and consumer has seen the rapid growth of client base and team at Map and Page.&lt;/p&gt; 
&lt;p&gt; Antonia has more than a decade&amp;rsquo;s experience in the free-to-air, commercial television industry having worked across a range of business units for the Seven Network (TV) including production, sport, publicity, events and sponsorship from 1995-2003.&lt;/p&gt; 
&lt;p&gt; Antonia managed event marketing and client relations across four Olympic Games, Rugby World Cups, Commonwealth Games and Melbourne Cup Carnivals reporting directly to the CEO.&lt;/p&gt; 
&lt;p&gt; In 2003, Antonia co-founded Launch Group a full service communications agency and in 2007 founded Map and Page in partnership with MRN...&lt;/p&gt;</bio> 

    </node> 
    <node> 
    <nid>3</nid> 
    <name>Julia Everingham</name> 
    <jobtitle>Group Account Director</jobtitle> 
    <photo>http://202.58.37.93/dev.mapandpage.com.au/backend/sites/default/files/MAP-holder_0.jpg</photo> 
    <bio>&lt;p&gt;In her role as Group Account Director, Julia specialises in the development of strategic public relations campaigns working across a range of clients including the Australian Jockey Club (AJC), Coca-Cola Amatil, Bluetongue, Maserati, Percy Marks, Surf Life Saving Australia and Diamond Guild of Australia.&lt;/p&gt; 

&lt;p&gt; Julia brings more than fifteen years of public relations experience to MAP having previously established and run the highly successful Oxygen Marketing Communication. Her experience includes developing, implementing and managing communication programs for major brands and events.&lt;/p&gt; 
&lt;p&gt; Her marketing communications expertise spans a broad array of industry groups including consumer, sport, telecommunications and media. Julia&amp;rsquo;s experience includes communication specialty areas of publicity and promotion, sports and event public relations, consumer marketing and luxury goods promotion.&lt;/p&gt; 
&lt;p&gt; Julia has worked on both client and agency side of the business. She provides clients with highly experienced communication counsel with strong expertise in media management and leveraging, with an extensive media network.&lt;/p&gt;</bio> 
    </node> 

</xml> 

這裏的動作:

var xmlLoader:URLLoader = new URLLoader(); 
var xmlData:XML = new XML(); 
//ignore white space 
xmlData.ignoreWhite=true; 

xmlLoader.addEventListener(Event.COMPLETE, LoadXML); 
var theURL:String = ("http://202.58.37.93/dev.mapandpage.com.au/backend/?q=xml/team2&cachebuster=" + new Date().getTime()); 
trace(theURL); 
xmlLoader.load(new URLRequest(theURL)); 

function LoadXML(e:Event):void { 

xmlData = new XML(e.target.data); 
ParseTeam2(xmlData); 

} 
function ParseTeam2(bookInput:XML):void { 

trace("XML Output"); 
trace("------------------------"); 
trace(bookInput); 
} 

閃存忽略<jobtitle><photo>標籤。

有沒有人有任何想法爲什麼?

+0

這不應該有所作爲,但如何'bookInput.toXMLString()'?另外,這可能不是問題,但根據xml規範,不能將xml(與任何情況下的組合 - 基本上是'/ xml/i')一起用作xml標籤名稱。 – Amarghosh 2010-06-29 05:52:33

回答

1

我已經試過了你的xml文件,它對我的​​預期效果。我只能建議你檢查你是否保存在UTF-8中,並使用Unix線結束。

package 
{ 
import flash.display.Sprite; 
import flash.events.Event; 
import flash.net.URLLoader; 
import flash.net.URLRequest; 

public class XMLTest extends Sprite 
{ 
    public function XMLTest() 
    { 
     var xmlLoader:URLLoader = new URLLoader(); 
     xmlLoader.addEventListener(Event.COMPLETE, loadXML); 
     var theURL:String = ("XMLTest.xml"); 
     xmlLoader.load(new URLRequest(theURL)); 
    } 

    private function loadXML(event:Event):void 
    { 
     var xmlData:XML = new XML(URLLoader(event.target).data); 

     // all of these trace the expected values: 
     trace(xmlData); 
     trace(xmlData..jobtitle); 
     trace(xmlData..photo); 
    } 
} 
} 

使用XML:

<?xml version="1.0" encoding="UTF-8" ?><xml> 
    <node> 
    <nid>2</nid> 
    <name>Antonia O&#039;Neill</name> 
    <jobtitle>Director</jobtitle> 
    <photo>http://202.58.37.93/dev.mapandpage.com.au/backend/sites/default/files/MAP-holder.jpg</photo> 
    <bio>&lt;p&gt;Antonia formed Map and Page in 2007 as an independent subsidiary of Macquarie Radio Network. In her role as Director she oversees corporate affairs and community relations for Macquarie Radio Network (2GB + 2CH), the Australian Jockey Club, John Singleton, Harvey Norman, Magic Millions, National Rugby League, and Maserati.&lt;/p&gt; 

&lt;p&gt; Her expertise in the full spectrum of communications; both corporate and consumer has seen the rapid growth of client base and team at Map and Page.&lt;/p&gt; 
&lt;p&gt; Antonia has more than a decade&amp;rsquo;s experience in the free-to-air, commercial television industry having worked across a range of business units for the Seven Network (TV) including production, sport, publicity, events and sponsorship from 1995-2003.&lt;/p&gt; 
&lt;p&gt; Antonia managed event marketing and client relations across four Olympic Games, Rugby World Cups, Commonwealth Games and Melbourne Cup Carnivals reporting directly to the CEO.&lt;/p&gt; 
&lt;p&gt; In 2003, Antonia co-founded Launch Group a full service communications agency and in 2007 founded Map and Page in partnership with MRN...&lt;/p&gt;</bio> 

    </node> 
    <node> 
    <nid>3</nid> 
    <name>Julia Everingham</name> 
    <jobtitle>Group Account Director</jobtitle> 
    <photo>http://202.58.37.93/dev.mapandpage.com.au/backend/sites/default/files/MAP-holder_0.jpg</photo> 
    <bio>&lt;p&gt;In her role as Group Account Director, Julia specialises in the development of strategic public relations campaigns working across a range of clients including the Australian Jockey Club (AJC), Coca-Cola Amatil, Bluetongue, Maserati, Percy Marks, Surf Life Saving Australia and Diamond Guild of Australia.&lt;/p&gt; 

&lt;p&gt; Julia brings more than fifteen years of public relations experience to MAP having previously established and run the highly successful Oxygen Marketing Communication. Her experience includes developing, implementing and managing communication programs for major brands and events.&lt;/p&gt; 
&lt;p&gt; Her marketing communications expertise spans a broad array of industry groups including consumer, sport, telecommunications and media. Julia&amp;rsquo;s experience includes communication specialty areas of publicity and promotion, sports and event public relations, consumer marketing and luxury goods promotion.&lt;/p&gt; 
&lt;p&gt; Julia has worked on both client and agency side of the business. She provides clients with highly experienced communication counsel with strong expertise in media management and leveraging, with an extensive media network.&lt;/p&gt;</bio> 
    </node> 

</xml> 
+0

謝謝詹姆斯。事實證明,這是一個服務器端問題。沒有你的幫助,我會一直追逐我的尾巴。 – tripper54 2010-06-30 01:03:35