0

Does anyone know how the XML syntax works in Actionscript 3? I copied over my XML file into AS so I can export an independent SWF, but it's giving me a whole bunch of syntax errors "1093: syntax error", on almost every single line.

var xml:XML = 
<images>
    <pic>images/3.png</pic>
    <painter>Painter name</painter>
    <title>画家1</title>
    <date></date>
</images>
<images>
    <pic>images/2.png</pic>
    <painter>Painter name</painter>
    <title>画家2</title>
    <date></date>
</images>
...
...
about 20 of these <images> sections

One of the parameters contains foreign characters. I've already tried turning all the "<" ">" and quotation/apostrophes into the HTML code, still doesn't work...

Thanks.

1 Answer 1

2

You need a root node. That is not valid xml as it stands right now.

An easy fix is to just wrap the <images> nodes in a <root> node like so

val xml:XML = 
<root>
    <images>
        <pic>images/3.png</pic>
        <painter>Painter name</painter>
        <title>画家1</title>
        <date></date>
    </images>
    ...
</root>

If you want your XML to map directly to an XMLList, you can use an unnamed root node (*note this is not valid XML, but AS3 doesn't mind)

<>
    <images>
        <pic>images/3.png</pic>
        <painter>Painter name</painter>
        <title>画家1</title>
        <date></date>
    </images>
    ...
</>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.