我有一個分配給ColdFusion變量的XML文檔。在本文檔中調用XmlSearch()
會生成一個XML節點數組。在其中一個XML節點上調用XmlSearch()
將產生與在原始XML文檔上調用它相同的輸出。XmlSearch()不處理數組中的單個XML節點
問題是什麼?
下面是一個代碼示例(CFSCRIPT):
// xmlSource is an XML file that has been read in
xmlDoc = XmlParse(xmlSource);
// "return" is a high-level XML node in xmlSource that appears more than one time
xmlNodeArray = XmlSearch(xmlDoc, "//return");
// a single "return" node from xmlDoc
xmlNode = xmlNodeArray[1];
// "recipients" is an XML node that appears one or more times beneath each "return" XML node
xmlArray = XmlSearch(xmlNode, "//recipients");
// this prints out all of the "recipients" nodes in xmlDoc instead of just from xmlNode
WriteDump(xmlArray);
嘗試使用「./recipients」作爲XPath。 – abbottmw
這可能會爲您帶來一些燈光:http://blog.adamcameron.me/2014/01/expectations-management-what-does.html –
@abbottmw'。/ recipients'工作,謝謝。 ColdFusion似乎在'XmlSearch()'的返回值中有或多或少的指針式變量數組......使得'xmlNode'中的整個原始'xmlDoc'可用。 – user3071284