2011-03-22 83 views
1

我試圖顯示XMLSearch返回的XML節點數據,並且顯示數據時出現問題。我試圖輸出數據是這樣的:XML搜索和顯示節點信息

<cfset xmlBeatles=XMLParse(ExpandPath("Beatles.xml"))> 
<cfset Qdata = XMLsearch(xmlBeatles,"//beatle[1]")> 

#Qdata.beatle.firstname.xmltext# or #Qdata[1].beatle.firstname.xmltext# 

,但我得到這個錯誤:

You have attempted to dereference a scalar variable of type class coldfusion.runtime.Array as a structure with members.

示例XML:

Screenshot of XML dump

回答

1

我能夠通過這樣做來提取數據Qdata[1].name.firstname.xmltext

0

您似乎缺少「名稱「元素。嘗試「Qdata.beatle.name.firstname.xmltext」,看看是否有效。

+0

感謝您的迴應保羅。可悲的是這個「Qdata.beatle.name.firstname.xmltext」不起作用。我得到了這個錯誤「您試圖將類型爲coldfusion.runtime.Array的標量變量解引用爲具有成員的結構。」任何建議? – user281867 2011-03-23 04:40:36