Create a reference to the default Namespace using the Namespace constructor: : namespace « XML « Flash / Flex / ActionScript

Home
Flash / Flex / ActionScript
1.Animation
2.Array
3.Class
4.Data Type
5.Development
6.Function
7.Graphics
8.Language
9.Network
10.Regular Expressions
11.Statement
12.String
13.TextField
14.XML
Flash / Flex / ActionScript » XML » namespace 
Create a reference to the default Namespace using the Namespace constructor:
 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var catalog:XML = <html xmlns:shop="http://www.example.com/furniture"
              xmlns="http://www.w3.org/1999/xhtml">
          <head>
            <title>Catalog</title>
          </head>
          <body>
            <shop:table shop:id="4875">
              <table border="1">
                <tr align="center">
                  <td>Item</td>
                  <td>Price</td>
                </tr>
                <tr align="left">
                  <td><shop:desc>Table</shop:desc></td>
                  <td><shop:price>9.99</shop:price></td>
                </tr>
              </table>
            </shop:table>
          </body>
        </html>
        
        var shopNS:Namespace = catalog.namespace("shop");
        
        //default xml namespace = shopNS;
        for each (var table:XML in catalog..table) {
          trace(table..desc + ": " + table..price);
        }
        

    }
  }
}

        
Related examples in the same category
1.Create a namespace
2.As with element and attribute names, we can use the properties wildcard (*) with namespaces.
3.Creating Namespace-Qualified Elements and Attributes
4.Working with XML Namespaces
5.Get xml namespace
6.Two Namespace objects are considered equal if, and only if, they have the same namespace name, regardless of their prefix.
7.Working with Namespaces in ActionScript
8.Namespace with prefix
9.Namespace objects return their URI value by default when the toString() method is used
10.Get prefix and uri from a namespace
11.Use the namespaceDelarations() method to return an Array of all the namespaces defined for a given element.
12.Using the :: Operator with namespace
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.