应用程序变得很慢?

发布于 2024-08-21 05:45:17 字数 66 浏览 3 评论 0原文

过滤和分配 XML 数据的不同方法有哪些 来控制。当我使用以下命令执行此操作时,我的应用程序会显示 数组和循环??

What are different approaches to filter and assign XML data
to controls. my application get show when I do this using
Array and looping??

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

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

发布评论

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

评论(1

老旧海报 2024-08-28 05:45:17

希望这有帮助。将来尝试更具体地回答您的问题。

使用 for 循环迭代 XML 的节点,如下所示:

var total:Number = 0;
for each (var property:XML in myXML.item)
{
    var q:int = Number(property.@quantity);
    var p:Number = Number(property.price);
    var itemTotal:Number = q * p;
    total += itemTotal;
    trace(q + " " + property.menuName + " $" + itemTotal.toFixed(2))
}
trace("Total: $", total.toFixed(2));

您可以使用括号运算符(和)来过滤具有特定元素名称或属性值的元素。考虑以下 XML 对象:

var x:XML = 
    <employeeList>
        <employee id="347">
            <lastName>Zmed</lastName>
            <firstName>Sue</firstName>
            <position>Data analyst</position>
        </employee>
        <employee id="348">
            <lastName>McGee</lastName>
            <firstName>Chuck</firstName>
            <position>Jr. data analyst</position>
        </employee>
    </employeeList>

以下表达式均有效:

x.employee.(lastName ==
   "McGee")--This is the second employee
   node. 

x.employee.(lastName ==
   "McGee").firstName--This is the   
   firstName property of the second   
   employee node. 

x.employee.(lastName
   == "McGee").@id--This is the value of    the id attribute of the second   
   employee node. 

x.employee.(@id ==
   347)--The first employee node.

x.employee.(@id ==
   347).lastName--This is the lastName  
   property of the first employee node.

x.employee.(@id > 300)--This is an
   XMLList with both employee   
   properties.

x.employee.(position.toString().search("analyst")
      > -1)--This is an XMLList with both position properties.

请参阅 http://livedocs.adobe.com/flex/3/html/help.html?content=13_Working_with_XML_04.html
了解更多信息。

Hope this helps. In the future try to be a bit more specific with your questions.

Use a for loop to iterate through nodes of the XML, as follows:

var total:Number = 0;
for each (var property:XML in myXML.item)
{
    var q:int = Number(property.@quantity);
    var p:Number = Number(property.price);
    var itemTotal:Number = q * p;
    total += itemTotal;
    trace(q + " " + property.menuName + " $" + itemTotal.toFixed(2))
}
trace("Total: $", total.toFixed(2));

You can use the parentheses operators-- ( and ) --to filter elements with a specific element name or attribute value. Consider the following XML object:

var x:XML = 
    <employeeList>
        <employee id="347">
            <lastName>Zmed</lastName>
            <firstName>Sue</firstName>
            <position>Data analyst</position>
        </employee>
        <employee id="348">
            <lastName>McGee</lastName>
            <firstName>Chuck</firstName>
            <position>Jr. data analyst</position>
        </employee>
    </employeeList>

The following expressions are all valid:

x.employee.(lastName ==
   "McGee")--This is the second employee
   node. 

x.employee.(lastName ==
   "McGee").firstName--This is the   
   firstName property of the second   
   employee node. 

x.employee.(lastName
   == "McGee").@id--This is the value of    the id attribute of the second   
   employee node. 

x.employee.(@id ==
   347)--The first employee node.

x.employee.(@id ==
   347).lastName--This is the lastName  
   property of the first employee node.

x.employee.(@id > 300)--This is an
   XMLList with both employee   
   properties.

x.employee.(position.toString().search("analyst")
      > -1)--This is an XMLList with both position properties.

See http://livedocs.adobe.com/flex/3/html/help.html?content=13_Working_with_XML_04.html
for more information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文