- Home /
Looping over XMLInStream Content
Hello All, I have an XML file that I need to access and retrieve data. The structure of the file is like so: [root][Tutorials][Names]a[/Names][Names]b[/Names]etc...[Names]z[/Names][/Tutorials][root]. I understand how to get to names and access the data. But the thing is I'm putting this information into an array. And I want to do something like this:
int index = 0;
inStream.Start("Root").List("Tutorials", delegate(XMLInStream entryStream) {
entryStream.Content("Name", out Array[index]);
index++;
}).End();
Does anyone know how I can achieve this looping with the XMLInStream class? If any clarification is need please let me know and I'll try my best to clarify my question. Thank you for the help Unity Community!
Answer by ATMEthan · Jan 21, 2013 at 06:13 PM
I have the answer now.
List<string> tutorialNames = new List<string>();
inStream.Start("Tutorials").Start("TutorialsName").List("Tutorial", delegate(XMLInStream entryStream)
{
string name;
entryStream.Content(out name);
tutorials.Add(name);
}).End().End();
totalNumbersOfTutorials = tutorials.Count;
setup = true;
This will populate the list with all of the nodes containing the tag "Tutorial" under the Tutorials->TutorialsName nodes
Your answer