as3²Ù×÷xmlÖ®¶þ
·¶ÀýÈçÏ£º
var xml:XML=
<body>
text1
<bar>barText1</bar>
<bar>barText1</bar>
text2
</body>
trace(xml.text());//Êä³ö£ºtext1text2
trace(xml.text()[0]);//Êä³ö£ºtext1
trace(xml.text()[1]);//Êä³ö£º text2
trace(xml.child(1).toXMLString());//Êä³ö£º<bar>barText1</bar>
trace(xml.child(1).toString());//Êä³ö£ºbarText1
?
toXMLString()·½·¨£ºÊ¼ÖÕ·µ»ØXML ¶ÔÏóµÄ¿ªÊ¼±êÇ©¡¢ÊôÐԺͽáÊø±êÇ©µÄ×Ö·û´®ÐÍʽ¡£
toString()·½·¨£ºÖ»ÊÇ°´×Ö·û´®ÐÎʽ·µ»Ø½ÚµãµÄÄÚÈÝ¡£
text()·½·¨£ºÔòÊÇ·µ»ØXML Îı¾½ÚµãµÄËùÓÐ XML ÊôÐ﵀ XMLList ¶ÔÏó£¬ÉÏÃæµÄÀý×Ó£¬ÓÐÁ½¸öÎı¾½Úµãtext1ºÍtext2¡£
11.3.2 XML½Úµã·ÃÎÊ
´æÈ¡½ÚµãÊÇʹÓÃXML¶ÔÏóµÄ»ù´¡£¬ÒªÓúÃXMLÏÈÒªÕÆÎÕ¹ÜÀíXMLÀàµÄ·½·¨£¬XMLÀàÌṩÁËÒÔϸ÷¹ÜÀí½ÚµãµÄ·½·¨¡£
1.·ÃÎÊXML¸÷½Úµã¡£
ÔÚѧϰ·ÃÎÊXML½ÚµãÇ°£¬ÒªÏÈŪÃ÷°×XML¸÷²ã´ÎµÄ¹ØϵºóÃ棬ҪʹÓÃÕâ¸ö²ã¼¶Óë½Úµã±àºÅÀ´·ÃÎʲ»Í¬Î»ÖõĽڵ㡣
ËäÈ»ÎÒÃÇ¿´À´£¬“<item>text1<item>”Ö»ÊÇÒ»¶Î°üº¬<item>¾í±êÔªËصÄ×Ö·û´®¶øÒÔ£¬µ«ÊǾ¹ýFlashÄÚ²¿µÄXML½âÎöÆ÷´¦Àíºó£¬XMLÀïµÄÿ¸öÔªËض¼»á±»Õ¹ÏÖ³ÉÊ÷×´µÄ²ã¼¶½á¹¹£¬¸÷²ãÖ®¼ä¶¼´æÔÚ¹æÂÉÐԵıàºÅ¡£ÎÒÃÇ°ÑÏÂÃæµÄ´úÂë·Ö½âÈçͼ11-12Ëùʾ¡£
var xml:XML=
<myxml>
<item>
<pro>proText</pro>
</item>
<item>text1</item>
<item>text2</item>
</myxml>
ͼ11-12ÓÃIEä¯ÀÀXML
Ïà¹ØÎĵµ£º
<?xml version="1.0" encoding="UTF-8"?>
<root>
<person id="1">
<username >xiaoma</username>
<password>xiaoma</password>
</person>
<person id="2">
<username>manager</username> ......
ÕâÊÇÒ»¸öÓÃJAVA W3C DOM ½øÐÐXML²Ù×÷µÄÀý×Ó£¬°üº¬Á˲éѯ¡¢Ôö¼Ó¡¢Ð޸ġ¢É¾³ý¡¢±£´æµÄ»ù±¾²Ù×÷¡£½ÏÍêÕûµÄÃèÊöÁËÒ»¸öXMLµÄÕû¸ö²Ù×÷Á÷³Ì¡£ÊʺϸÕÈëÃÅJAVA XML²Ù×÷µÄÅóÓѲο¼ºÍѧϰ¡£
¼ÙÉèÓÐXMLÎļþ£ºtest1.xml
<?xml version="1.0" encoding="GBK"?>
<books>
<book>
<name>¹þÀﲨÌØ</name>
......
/// <summary>
/// ¶ÁÈ¡Êý¾Ý¼¯²¢¼ÓÈ뻺´æ
/// sea 2009-12-11
/// </summary>
&nb ......
XML Schema ²Î¿¼ÊÖ²á
XSD ÔªËØ
ÔªËØ
½âÊÍ
all
¹æ¶¨×ÓÔªËØÄܹ»ÒÔÈÎÒâ˳Ðò³öÏÖ£¬Ã¿¸ö×ÓÔªËؿɳöÏÖÁã´Î»òÒ»´Î¡£
annotation
annotation ÔªËØÊÇÒ»¸ö¶¥²ãÔªËØ£¬¹æ¶¨ schema µÄ×¢ÊÍ¡£
any
ʹ´´×÷Õß¿ÉÒÔͨ¹ýδ±» schema ¹æ¶¨µÄÔªËØÀ´À©Õ¹ XML Îĵµ¡£
anyAttribute
Ê ......