如何通过属性访问子节点?
我正在尝试创建一个图片库:
<card>
<product catalog="Thread Works">
<name>AK E001</name>
<price>45</price>
<path>assets\cards\AK_E001.jpg</path>
</product>
<product catalog="Paper Work">
<name>AK E001</name>
<price>45</price>
<path>assets\cards\AK_PP003.jpg</path>
</product>
<product catalog="Thread Works">
<name>AK E002</name>
<price>50</price>
<path>assets\cards\AK_E002.jpg</path>
</product>
我可以访问该属性,但如果我选择“Thread Works”,我只想访问
带有子节点,用于将项目添加到数组集合任何帮助谢谢
I am trying to create an image gallery :
<card>
<product catalog="Thread Works">
<name>AK E001</name>
<price>45</price>
<path>assets\cards\AK_E001.jpg</path>
</product>
<product catalog="Paper Work">
<name>AK E001</name>
<price>45</price>
<path>assets\cards\AK_PP003.jpg</path>
</product>
<product catalog="Thread Works">
<name>AK E002</name>
<price>50</price>
<path>assets\cards\AK_E002.jpg</path>
</product>
I can access the attribute, but if i am selecting "Thread Works" i want only access
with children node , for additem to array collection any Help Thanks
<product catalog="Thread Works">
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请参阅 http://livedocs.adobe.com/flex/ 3/html/help.html?content=13_Working_with_XML_08.html
在您的情况下:
var x:XML; //用您的数据填充Xml
var threadWorks:XML = x.product.(@catalog=="Thread Works");
编辑:
警告:不要忘记 .产品和@catalog之间
Refer http://livedocs.adobe.com/flex/3/html/help.html?content=13_Working_with_XML_08.html
in your case:
var x:XML; //fill Xml with your data
var threadWorks:XML = x.product.(@catalog=="Thread Works");
EDIT:
Warning: Don't forget the . between product and @catalog