简体   繁体   中英

Flash AS2 , XML doesn't accept HTML inside?

A simple as2 flash app. that is reading an XML file.

Here is the Flash AS2:

function loadXML(loaded) {
    if (loaded) {
        _root.inventor = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
        _root.comments = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
        name_txt.text = _root.inventor;
        comment_txt.text = _root.comments;
    } else {
        content = "file not loaded!";
    }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("inventors.xml");

And here is my XML:

<?xml version="1.0"?>
<y>
    <t>
        <name>Name Here</name>
        <description>Some Html or what not in here, <b>I'm BOLD</b></description>
    </t>
    <t>
        <name>Name 2 Here</name>
        <description>Some Html or what not in here</description>
    </t>
    <t>
        <name>Name 3 Here</name>
        <description>Some Html or what not in here</description>
    </t>
</y>

The problem is that the flash dynamic text box will not read the XML (HTML) as HTML -- so the <b>I'm BOLD</b> tag doesn't come through as I'm BOLD in flash?? What I'm I missing?? Thanks.

I found it!!! And it works!!

In Flash I need to change the variables to recognize HTML:

Like so:

        name_txt.htmlText  = _root.inventor;
        comment_txt.htmlText  = _root.comments;

Then in my XML file, I needed to use CDATA, like so:

<description><![CDATA[This is <ul><li>bold</li><li>bold</li><li>bold</li><li>bold</li></ul>]]></description>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM