开发者

Recursively Parse XMl in Flex / As3

Ho,

how can I recursively analyze/modify XML in Flex / As3?

Let's say I have this XML:

        <div>
          <P ALIGN="center">
            <FONT FACE="ArialV" SIZE="15" COLOR="#000000" LETTERSPACING="0" KERNING="1"> </FONT>
          </P>
          <开发者_运维百科;P ALIGN="center">
            <FONT FACE="ArialV" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="1">Copyright 2010555</FONT>
          </P>
        </div>

How can I find/change, let's say all 'font' tags that have 'size' attribute and multiply it by 2 (no matter where it is)?

Thanks in advance!


ActionScript has an E4X implementation that makes working with XML a breeze, checkout the docs: http://livedocs.adobe.com/flex/3/langref/XML.html

For your particular problem, do the following:

for each(var fontElement:XML in myXML..FONT) {
    fontElement.@SIZE = fontElement.@SIZE * 2;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜