Download the files here.
TUTORIAL CONTENTS
  • Introduction
  • Flash/XML Syntax
  • Accessing nodes
  • Digging deeper
  • Power of Attributes
  • HTML and Text in XML
  • Making a Search Engine
  • Preloading XML files
  • XML/FLASH SITES AND TUTORIALS
  • Tupps web site
  • Flash 5 and XML
  • XML Table Constructor Kit
  • Using an XML file to load Chart components
  • Macromedia XML tutorial
  • Integrating XML and Flash in a Web Application
  • AUTHOR´s XML TUTORIALS/FILES
  • XML searchable database I
  • URLs and Asfunctions (II)
  • XML searchable database III
  • XML database Component
  • XML slideshow Component
  • XML scroller menu Component
  • Flash - XML Tutorial

    Power of Attributes

    So far we have learnt what childNodes are, XML elements or textnodes. We have learnt what is the relationship to each other: parent, child, firstChild, lastChild, nextSibling or previousSibling. But one element is missing, which is the attribute. Before we go further, we will look at the syntax of the attribute.

                                     <?xml version="1.0"?>
                                     <models>
                                         <susan name="Susan Black" language="german">    //name and language attributes
                                      Susan Black
                                      age: 21
                                      eye color: dark blue
                                      hair color: black
                                      foreign language: german
                                          </susan>
                                      <models>
    

    Attributes are added to nodes and the attribute content is always in quotations. Each attribute of one node should always have its unique name. We should not name Susan Black and german with the same attribute unless we put the text together under one attribute name. How do we parse XML to get to attributes? This is shown in the actionscript below.

                                      function listItems(model01){
                                           var fItem = model01.firstChild.attributes;
                                           textField1.htmlText=fItem.name;
                                           textField2.htmlText = fItem.language;
                                      }
    

    We just add the attributes property to a node name. If the node has an attribute we have to specify it by naming the attribute as shown here with model01.firstChild.attributes.name. If we want only lower case we add that: model01.firstChild.attributes.name.toLowerCase();. Here is how that little xml file will be parsed by the script as shown.

    Before we create our final search engine file we need to learn about the use of HTML in XML and how the flashplayer handles that.


    PREVIOUS          NEXT