6 Replies Latest reply on Apr 20, 2006 2:55 AM by Lacrymocéphale

    How To Set Bold, Italic, And Urls In Xml Files

    Hrududu
      I've been experimenting with XML. No doubt you guys have too.

      Do any of you know how to set Bold, Italic, and URLs in an XML file? regular <b>, <i>, and <a href> just don't kick in.

      Thanks,

      Hrududu
        • 1. How To Set Bold, Italic, And Urls In Xml Files
          blemmo Level 1
          Hi,

          XML isn't supposed to contain display information. It's common use to seperate content and appearance, so that the XML contains only the data, and the display information is defined in an extra file, a XSL or a CSS document.
          Now for your question: what do you have in mind with your xml files? I think Flash doesn't display raw xml, only html in html enabled textfields. If you want to store html in a xml file, you have to escape the special characters that form the xml (and also html) markup, otherwise the tags will get parsed as another xml tag, or the parsing may fail completely. There are some predefined replacements:
          &amp; (&)
          &lt; (<)
          &gt; (>)
          &apos; (')
          &quot; (")
          So you could use it like this:
          <link url="&lt;a href=&quot;www.domain.org&quot;&gt;linktext&lt;/a&gt;" />
          The parser should generate this from that line:
          <link url="<a href="www.domain.org">linktext</a>" />
          You see that this screws up the xml's tag order, that's why you have to use the escaped expressions. Then you could assign the value of the 'url' attribute of the 'link' node to a html enabled textfield, which would display it as a normal link.
          FYI, Flash parses atrributes of a node faster than content (= the stuff between opening and ending tag), so it's a good idea to have the data stored in the attributes.

          hth,
          blemmo
          • 2. Re: How To Set Bold, Italic, And Urls In Xml Files
            Hrududu Level 1
            Hi Blemmo,

            Thanks for replying. Let me be more specific.

            I read the following article: http://www.macromedia.com/devnet/flash/art...ctor_print.html

            and while the prototype works great, I can't add Bold, Italic or Links.

            Any ideas?
            • 3. Re: How To Set Bold, Italic, And Urls In Xml Files
              blemmo Level 1
              Please post the link again, it's broken.
              • 4. Re: How To Set Bold, Italic, And Urls In Xml Files
                Lacrymocéphale
                <link url="&lt;a href=&quot;www.domain.org&quot;&gt;linktext&lt;/a&gt;" />

                I do not understand why this unuseful tricks.
                <a href="www.domain.org">linktext</a> is a pure XML node with a text node inside. No need to embed it for a parser. Just know how to build a HTML-for-textField from XML.
                • 5. Re: How To Set Bold, Italic, And Urls In Xml Files
                  blemmo Level 1
                  Lacrymocéphale,

                  you're right, it was just an example (maybe a strange one). I don't know what the OP has in mind, but as he wants to use xml, and not html, I can imagine that there is more info than just the url in a xml node. There sure are other ways, and the example isn't very good indeed; I only wanted to show why html embedded in xml may need some special treatment.

                  greets,
                  blemmo
                  • 6. Re: How To Set Bold, Italic, And Urls In Xml Files
                    Lacrymocéphale Level 1
                    It doesn't realy matter blemmo .
                    I just want Hrududu to not understanding false things.
                    As XHTML is XML, XHTML node can be use in XML document. I do not want him to think that there is restriction on this.
                    After that, everyone create the XML shema he wants.
                    The fact that Hrududu haven't what he wants is not linked to the tag that he quotes (cf. About supported HTML tags) but, probably, to how he handle and treat his XML