2011-06-01 72 views
2

自定義XML文本的內容有一個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文本內容。希望你能幫助我找到解決方法,謝謝。

+0

HTTP://www.air-tutorial .com/tree-xml-flex-air - 此鏈接可能對您有所幫助。 – Anandh 2011-06-09 22:13:54

回答

0

要獲取XML節點的內容,請使用內置於as3的E4X標準導航到所需的節點。爲這個偉大的資源是以下網站:http://dispatchevent.org/roger/as3-e4x-rundown/

以下是如何跟蹤<Title>節點的內容與屬性"15 FitF 600"一個例子:

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>