gpt4 book ai didi

xml - Flex e4x - 按多个属性选择

转载 作者:行者123 更新时间:2023-12-04 07:00:03 26 4
gpt4 key购买 nike

<EFM>
<projects>
<project name="EFM Columbus Supply Chain Project">
<characteristics>
<characteristic name="Types of Data">
<textDescription></textDescription>
<options>
<option name="Commodity Flow" value="True"/>
<option name="Industry Assets" value="False"/>
<option name="Trade Data" value="True"/>
<option name="Infrastructure" value="False"/>
<option name="Economic Data" value="False"/>
<option name="Benefits Information" value="True"/>
<option name="Supply Chain Event Data" value="False"/>
<option name="Physical Movement Data" value="False"/>
<option name="Other" value="True"/>
</options>
</characteristic>
</characteristics>
</project>
</projects>
</EFM>

我想按此条件选择节点的 XMLList
<Projects>.<project>.@name = x    &&  <Projects>.<project>.<characteristics>.<characteristic>.<options>.<option>.(@name == y && @value == z)

本质上通过两个属性 [名称和值] 查询给定的项目名称

最佳答案

trace(xml.projects.project.(@name == "EFM Columbus Supply Chain Project").characteristics.characteristic.options.option.(@name == "Other" && @value == "True").toXMLString());

//traces <option name="Other" value="True"/>

//broken down to fit in the screen:
trace(
xml.projects.project.(
@name == "EFM Columbus Supply Chain Project"
).characteristics.characteristic.options.option.(
@name == "Other" && @value == "True"
).toXMLString()
);

更新:以防万一您想获取项目标签而不是选项标签:
var xml:XML = 
<EFM>
<projects>
<project name="EFM 1" id="wrong">
<characteristics>
<characteristic name="Types of Data">
<options>
<option name="Benefits Information" value="True"/>
<option name="Supply Chain Event Data" value="False"/>
<option name="Physical Movement Data" value="False"/>
<option name="Other" value="True"/>
</options>
</characteristic>
</characteristics>
</project>
<project name="EFM 1" id="right">
<characteristics>
<characteristic name="Types of Data">
<options>
<option name="Benefits Information" value="True"/>
<option name="Supply Chain Event Data" value="False"/>
<option name="Physical Movement Data" value="False"/>
<option name="Other" value="False"/>
</options>
</characteristic>
</characteristics>
</project>
<project name="EFM 2" id="wrong">
<characteristics>
<characteristic name="Types of Data">
<options>
<option name="Benefits Information" value="True"/>
<option name="Supply Chain Event Data" value="False"/>
<option name="Physical Movement Data" value="False"/>
<option name="Other" value="False"/>
</options>
</characteristic>
</characteristics>
</project>
</projects>
</EFM>;

E4X:
trace(xml.projects.project.(@name == "EFM 1" && characteristics.characteristic.options.option.(@name == "Other").@value == "False").toXMLString());

//broken down to fit in the screen
trace(
xml.projects.project.(
@name == "EFM 1" && characteristics.characteristic.options.option.(
@name == "Other"
).@value == "False"
).toXMLString()
);

输出:
<project name="EFM 1" id="right">
<characteristics>
<characteristic name="Types of Data">
<options>
<option name="Benefits Information" value="True"/>
<option name="Supply Chain Event Data" value="False"/>
<option name="Physical Movement Data" value="False"/>
<option name="Other" value="False"/>
</options>
</characteristic>
</characteristics>
</project>

关于xml - Flex e4x - 按多个属性选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2013917/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com