【问题标题】:How to show custom xml text contents in tree如何在树中显示自定义 xml 文本内容
【发布时间】:2011-06-01 09:09:48
【问题描述】:
我有一个xml文件,它的结构如下:
<Bookmark>
<Title Action="GoTo" Page="14 FitH 670" >1. internal diseases
<Title Action="GoTo" Page="14 FitH 463" >gastroesophageal reflu
</Title>
<Title Action="GoTo" Page="15 FitH 600" >gastritis
</Title>
<Title Action="GoTo" Page="15 FitH 215" >peptic ulcer
</Title>...
我找了几个例子它使用 Xml 属性显示为树组件的标签。但我想在树组件中显示这些 xml 文本内容。但我找不到如何将这些 xml 文本内容显示为标签的示例。希望您能帮助我找到解决方案,谢谢。
【问题讨论】:
标签:
xml
apache-flex
actionscript-3
【解决方案1】:
要获取 XML 节点的内容,请使用 as3 中内置的 E4X 标准导航到所需的节点。一个很好的资源是以下站点:http://dispatchevent.org/roger/as3-e4x-rundown/
以下示例说明如何使用属性"15 FitF 600" 跟踪<Title> 节点的内容:
var xml:XML =
<Bookmark>
<Title Action="GoTo" Page="14 FitH 670" >1. internal diseases</Title>
<Title Action="GoTo" Page="14 FitH 463" >gastroesophageal reflu</Title>
<Title Action="GoTo" Page="15 FitH 600" >gastritis</Title>
<Title Action="GoTo" Page="15 FitH 215" >peptic ulcer</Title>
</Bookmark>
trace (xml.Title.(@Page == "15 FitH 600")); //gastritis
trace (xml.Title.(@Page == "15 FitH 600").toString()); //gastritis
trace (xml.Title.(@Page == "15 FitH 600").valueOf()); //gastritis
trace (xml.Title.(@Page == "15 FitH 600").toXMLString()); //<Title Action="GoTo" Page="15 FitH 600">gastritis</Title>