Hi Unity Community
I am trying to search through an XML document (using the XmlDocument class) nodes containing a specified string (in this test I’’m looking for 'Logs’) and then catch the value of matching node parent’s name attribute.
However I’m messing this up somewhere along the way, it’s currently returning each of the node parent names in the doc (as opposed to just the names of those who match). Can anyone help with my logic to make this work properly?
Many thanks in advance,
Ryan
Current code:
var mpo = xmlRoot.SelectNodes("MetaPipeObject");
for (var i = 0; i < mpo.Count; i++)
{
var curNode = mpo*;*
_ var nodeCheck = curNode.SelectNodes(“//*[contains(text(), ‘Logs’)]”);_
-
Debug.Log("nodeCheck: " + nodeCheck.Count);* -
if (nodeCheck.Count > 1)* -
{* -
Debug.Log(curNode.SelectSingleNode("@name").Value);* -
}* -
}*
}
Example XML snippet:
TestObj_EvanLogs04.obj
/Users/ryanachten/Documents/UnityTests/MetaPipeline_TestModels/CRM_TestObjs/TestObj_EvanLogs/TestObj_EvanLogs04/TestObj_EvanLogs04.obj
/Users/ryanachten/Documents/UnityTests/MetaPipeline_TestModels/CRM_TestObjs/TestObj_EvanLogs/TestObj_EvanLogs03/TestObj_EvanLogs.jpg
/Users/ryanachten/Documents/UnityTests/MetaPipeline/Assets/ScreenShot.png
Ryan Achten
03/10/2015
Logs with graffiti found out by Evan’s Bay
Ryan Achten
31/05/2015
Photogrammetric