0
我試圖通過Unity3D內部的XML文檔(使用uJS和MSDN XmlDocument類)搜索包含指定字符串的節點(在此測試中,我正在尋找'日誌'),然後捕獲匹配節點父節點的屬性值。搜索XML文檔的字符串
但是我把這件事搞亂了;它目前將的所有的if語句(而不僅僅是那些匹配的)傳遞給if語句,並因此返回XML文檔中的所有父名稱。任何人都可以用我的邏輯幫助我正確地工作嗎?
很多感謝,
瑞安
當前代碼:
var mpo = xmlRoot.SelectNodes("MetaPipeObject");
for (var i = 0; i < mpo.Count; i++)
{
var curNode = mpo[i];
var nodeCheck = curNode.SelectNodes("//*[contains(text(), 'Logs')]");
Debug.Log("nodeCheck: " + nodeCheck.Count);
if (nodeCheck.Count > 1)
{
Debug.Log(curNode.SelectSingleNode("@name").Value);
}
}
}
XML片段:
<MetaPipeObject name="Logs with graffiti">
<FileName>TestObj_EvanLogs04.obj</FileName>
<MeshLocation>/Users/ryanachten/Documents/UnityTests/MetaPipeline_TestModels/CRM_TestObjs/TestObj_EvanLogs/TestObj_EvanLogs04/TestObj_EvanLogs04.obj</MeshLocation>
<TexLocation>/Users/ryanachten/Documents/UnityTests/MetaPipeline_TestModels/CRM_TestObjs/TestObj_EvanLogs/TestObj_EvanLogs03/TestObj_EvanLogs.jpg</TexLocation>
<ObjImgCap>/Users/ryanachten/Documents/UnityTests/MetaPipeline/Assets/fuck you_ScreenShot.png</ObjImgCap>
<ContribName>Ryan Achten</ContribName>
<ContribDate>03/10/2015</ContribDate>
<Description>Logs with graffiti found out by Evan's Bay</Description>
<ModelInfo>
<ModelCreator>Ryan Achten</ModelCreator>
<ModelCreateDate>31/05/2015</ModelCreateDate>
<ModelCreateType>Photogrammetric</ModelCreateType>
</ModelInfo>
<ContextualInfo />
</MetaPipeObject>
<MetaPipeObject name="Punch (from Paul Jen">
<FileName>DaotfPunch03.obj</FileName>
<MeshLocation>/Users/ryanachten/Documents/UnityTests/MetaPipeline_TestModels/CRM_TestObjs/TestObj_DaotfPunch/DaotfPunch03/DaotfPunch03.obj</MeshLocation>
<TexLocation>/Users/ryanachten/Documents/UnityTests/MetaPipeline_TestModels/CRM_TestObjs/TestObj_DaotfPunch/DaotfPunch03/Punch_McorTex_merged.JPG</TexLocation>
<ObjImgCap>
</ObjImgCap>
<ContribName>Ryan Achten</ContribName>
<ContribDate>04/10/2015</ContribDate>
<Description>3D model of Judy based on Paul Jenden's costume concept illustrations for the project Digital Achives of the Future</Description>
<ModelInfo>
<ModelCreator>ard and Ryan Achten</ModelCreator>
<ModelCreateDate>26/02/2015</ModelCreateDate>
<ModelCreateType>Design</ModelCreateType>
</ModelInfo>
<ContextualInfo />
</MetaPipeObject>