Flex reads XML (with and without namespaces)

Source: Internet
Author: User
Tags xspf

XML with namespace

<? XML version = "1.0" encoding = "UTF-8" ?>
< Root Version = "1" Xmlns = "Http://xspf.org/ns/0" >
< Users ID = "User" >
< User >
< User_name Name = "Zzz" > Zhang San </ User_name >
< User_age > 23 </ User_age >
< User_birth > 1984-02-21 </ User_birth >
< Email > Zhangsan@hotmail.com </ Email >
</ User >
</ Users >
</ Root >

 

XML without a namespace

<? XML version = "1.0" encoding = "UTF-8" ?>
< Root Version = "1" >
< Users ID = "User" >
< User >
< User_name Name = "Zzz" > Zhang San </ User_name >
< User_age > 23 </ User_age >
< User_birth > 1984-02-21 </ User_birth >
< Email > Zhangsan@hotmail.com </ Email >
</ User >
</ Users >
</ Root >

 

Read method example

VaR Gxml: XML = XML (event. Result );
Trace (gxml ); // Output the entire XML

VaR NS: namespace =   New Namespace ( " Http://xspf.org/ns/0/ " );
Trace (gxml. NS: users. NS: User. NS: user_name.tostring ()); // Output XML with namespace

Trace (gxml. Users. User. user_name.tostring ()); // Output XML without a namespace

 

translate namespaces into namespaces. To prevent tag conflicts in XML, if xmlns is defined in XML, the value is read using the "namespace: Sub-tag" method.
Note: namespace cannot be used to read attributes in tags.
for example, the ID attribute in the NS: User label cannot be written as ns: user. NS: @ ID, which should be written as ns: user. @ ID.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.