使用动作脚本 3 获取所需的 XML 标签和所需的子标签?

发布于 2024-12-04 04:18:27 字数 2529 浏览 1 评论 0原文

我有一个 XML 架构。我只想使用操作 script3 代码读取表标签及其几何标签。任何想法。

<table name="TableBase 1" id="TableBase3010" overflow="false" direction="lr-tb" suppress-empty-lines="false">
      <style-ref name="default"/>
      <geometry size="absolute" position="absolute">
        <location left="117" top="102"/>
        <size width="341" height="80"/>
        <transform rotation="0"/>
      </geometry>
      <columns number-of-columns="1" gutter="0" align-bottoms="false"/>
      <header>
        <row>
          <cell>
            <objects>
              <text name="SingleLineText3081" id="ElxSingleLineText3081">
                <style-ref name="default"/>
                <geometry size="absolute" position="absolute">
                  <location left="0" top="0"/>
                  <size width="341" height="20"/>
                  <transform rotation="0"/>
                </geometry>
                <content value="Text"/>
              </text>
            </objects>
          </cell>
        </row>
      </header>

      <body>
        <row>
          <cell>
            <objects>
              <text name="SingleLineText3150" id="ElxSingleLineText3150">
                <style-ref name="default"/>
                <geometry size="absolute" position="absolute">
                  <location left="0" top="0"/>
                  <size width="341" height="20"/>
                  <transform rotation="0"/>
                </geometry>
                <content value="Text"/>
              </text>
            </objects>
          </cell>
        </row>
      </body>
      <footer>
        <row>
          <cell>
            <objects>
              <text name="SingleLineText3279" id="ElxSingleLineText3279">
                <style-ref name="default"/>
                <geometry size="absolute" position="absolute">
                  <location left="0" top="0"/>
                  <size width="341" height="20"/>
                  <transform rotation="0"/>
                </geometry>
                <content value="Text"/>
              </text>
            </objects>
          </cell>
        </row>
      </footer>
    </table>

提前致谢 !!!!!!!

I have a XML schema.I want to read only table tag and its geometery tag using action script3 code.Any Idea.

<table name="TableBase 1" id="TableBase3010" overflow="false" direction="lr-tb" suppress-empty-lines="false">
      <style-ref name="default"/>
      <geometry size="absolute" position="absolute">
        <location left="117" top="102"/>
        <size width="341" height="80"/>
        <transform rotation="0"/>
      </geometry>
      <columns number-of-columns="1" gutter="0" align-bottoms="false"/>
      <header>
        <row>
          <cell>
            <objects>
              <text name="SingleLineText3081" id="ElxSingleLineText3081">
                <style-ref name="default"/>
                <geometry size="absolute" position="absolute">
                  <location left="0" top="0"/>
                  <size width="341" height="20"/>
                  <transform rotation="0"/>
                </geometry>
                <content value="Text"/>
              </text>
            </objects>
          </cell>
        </row>
      </header>

      <body>
        <row>
          <cell>
            <objects>
              <text name="SingleLineText3150" id="ElxSingleLineText3150">
                <style-ref name="default"/>
                <geometry size="absolute" position="absolute">
                  <location left="0" top="0"/>
                  <size width="341" height="20"/>
                  <transform rotation="0"/>
                </geometry>
                <content value="Text"/>
              </text>
            </objects>
          </cell>
        </row>
      </body>
      <footer>
        <row>
          <cell>
            <objects>
              <text name="SingleLineText3279" id="ElxSingleLineText3279">
                <style-ref name="default"/>
                <geometry size="absolute" position="absolute">
                  <location left="0" top="0"/>
                  <size width="341" height="20"/>
                  <transform rotation="0"/>
                </geometry>
                <content value="Text"/>
              </text>
            </objects>
          </cell>
        </row>
      </footer>
    </table>

THANKS IN ADVANCE !!!!!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半葬歌 2024-12-11 04:18:27
<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Declarations>
        <fx:XML id="treeDP">
            <table name="TableBase 1" id="TableBase3010" overflow="false" direction="lr-tb" suppress-empty-lines="false">
                <style-ref name="default"/>
                <geometry size="absolute" position="absolute">
                    <location left="117" top="102"/>
                    <size width="341" height="80"/>
                    <transform rotation="0"/>
                </geometry>
                <columns number-of-columns="1" gutter="0" align-bottoms="false"/>
                <header>
                    <row>
                        <cell>
                            <objects>
                                <text name="SingleLineText3081" id="ElxSingleLineText3081">
                                    <style-ref name="default"/>
                                    <geometry size="absolute" position="absolute">
                                        <location left="0" top="0"/>
                                        <size width="341" height="20"/>
                                        <transform rotation="0"/>
                                    </geometry>
                                    <content value="Text"/>
                                </text>
                            </objects>
                        </cell>
                    </row>
                </header>

                <body>
                    <row>
                        <cell>
                            <objects>
                                <text name="SingleLineText3150" id="ElxSingleLineText3150">
                                    <style-ref name="default"/>
                                    <geometry size="absolute" position="absolute">
                                        <location left="0" top="0"/>
                                        <size width="341" height="20"/>
                                        <transform rotation="0"/>
                                    </geometry>
                                    <content value="Text"/>
                                </text>
                            </objects>
                        </cell>
                    </row>
                </body>
                <footer>
                    <row>
                        <cell>
                            <objects>
                                <text name="SingleLineText3279" id="ElxSingleLineText3279">
                                    <style-ref name="default"/>
                                    <geometry size="absolute" position="absolute">
                                        <location left="0" top="0"/>
                                        <size width="341" height="20"/>
                                        <transform rotation="0"/>
                                    </geometry>
                                    <content value="Text"/>
                                </text>
                            </objects>
                        </cell>
                    </row>
                </footer>
            </table>    
    </fx:XML>

</fx:Declarations>
<fx:Script>
    <![CDATA[
        protected function onClick(event:Event):void
        {
        for each(var item:XML in treeDP){
            textArea1.text=item;
            textArea2.text=item.child("geometry");
            }
        }
    ]]>
</fx:Script>

<s:Button id="Click" click="onClick(event)" x="1" y="57" label="Click"/>
<mx:TextArea id="textArea1" x="95" y="17" width="456" height="335"/>
<mx:TextArea id="textArea2" x="559" y="17" width="369" height="336"/>
</s:Application>
<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Declarations>
        <fx:XML id="treeDP">
            <table name="TableBase 1" id="TableBase3010" overflow="false" direction="lr-tb" suppress-empty-lines="false">
                <style-ref name="default"/>
                <geometry size="absolute" position="absolute">
                    <location left="117" top="102"/>
                    <size width="341" height="80"/>
                    <transform rotation="0"/>
                </geometry>
                <columns number-of-columns="1" gutter="0" align-bottoms="false"/>
                <header>
                    <row>
                        <cell>
                            <objects>
                                <text name="SingleLineText3081" id="ElxSingleLineText3081">
                                    <style-ref name="default"/>
                                    <geometry size="absolute" position="absolute">
                                        <location left="0" top="0"/>
                                        <size width="341" height="20"/>
                                        <transform rotation="0"/>
                                    </geometry>
                                    <content value="Text"/>
                                </text>
                            </objects>
                        </cell>
                    </row>
                </header>

                <body>
                    <row>
                        <cell>
                            <objects>
                                <text name="SingleLineText3150" id="ElxSingleLineText3150">
                                    <style-ref name="default"/>
                                    <geometry size="absolute" position="absolute">
                                        <location left="0" top="0"/>
                                        <size width="341" height="20"/>
                                        <transform rotation="0"/>
                                    </geometry>
                                    <content value="Text"/>
                                </text>
                            </objects>
                        </cell>
                    </row>
                </body>
                <footer>
                    <row>
                        <cell>
                            <objects>
                                <text name="SingleLineText3279" id="ElxSingleLineText3279">
                                    <style-ref name="default"/>
                                    <geometry size="absolute" position="absolute">
                                        <location left="0" top="0"/>
                                        <size width="341" height="20"/>
                                        <transform rotation="0"/>
                                    </geometry>
                                    <content value="Text"/>
                                </text>
                            </objects>
                        </cell>
                    </row>
                </footer>
            </table>    
    </fx:XML>

</fx:Declarations>
<fx:Script>
    <![CDATA[
        protected function onClick(event:Event):void
        {
        for each(var item:XML in treeDP){
            textArea1.text=item;
            textArea2.text=item.child("geometry");
            }
        }
    ]]>
</fx:Script>

<s:Button id="Click" click="onClick(event)" x="1" y="57" label="Click"/>
<mx:TextArea id="textArea1" x="95" y="17" width="456" height="335"/>
<mx:TextArea id="textArea2" x="559" y="17" width="369" height="336"/>
</s:Application>
第七度阳光i 2024-12-11 04:18:27

让我们假设您的 XML 存储在名为“xml”的变量中

var xml:XML;

,现在 xml 将存储您的标签,您可以获取 XMLList 形式的几何详细信息

var xmlList:XMLList = xml.child("geometry")
trace(xml.child("geometry")[0].toXMLString());//<location left="117" top="102"/>
trace(xml.child("geometry")[1].toXMLString());//<size width="341" height="80"/>

Let us assume your XML is stored in a variable called 'xml'

var xml:XML;

Now xml will store your tag and you can get the geometry details as XMLList

var xmlList:XMLList = xml.child("geometry")
trace(xml.child("geometry")[0].toXMLString());//<location left="117" top="102"/>
trace(xml.child("geometry")[1].toXMLString());//<size width="341" height="80"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文