im looking for a way to load data from my xml to lists that i can edit the items and then load the changes back to the xml file;
<game id="1" name="animals" instruction=" instruction here ">
<words>
<word wordName="Weasel" categoryCode="1" categoryName="Mammals" />
<word wordName="Dog" categoryCode="1" categoryName="Mammals" />
<word wordName="Cat" categoryCode="1" categoryName="Mammals" />
<word wordName="Snake" categoryCode="2" categoryName="Reptiles" />
<word wordName="Chameleon" categoryCode="2" categoryName="Reptiles" />
<word wordName="agama" categoryCode="2" categoryName="Reptiles" />
<word wordName="Chicken" categoryCode="3" categoryName="Birds" />
<word wordName="Peacock" categoryCode="3" categoryName="Birds" />
<word wordName="Pigeon" categoryCode="3" categoryName="Birds" />
</words>`
for example: then i load my page, there will be 5 lists, (2 of them will be empty at the moment), and the other 3 will be “mammals” “reptiles” and “birds”. under each on of those will be a list of all the items other that list. under mammals: weasel, dog, cat and so on.
im looking for a way to let my user change everything, add 2 more nodes (there for the extra empty lists), change the wordName value, change the categoryName value, add more values etc…
anyone got any suggestions on how to make the list? which component can i use?
im programing in c# and on visual studio 2010.
thanks 🙂
You can start with:
With the root node, you can then find the word children with:
Then loop over the wordList view each
XElement wordto get data (there are plenty of examples of that here and elsewhere, just search for it). And you can add more to any XElement with its.Add()method. If you want to add it to the"words"element, you can search for that with:The
//words[word]inXPathSelectElementmeans.Descendants("words") that has a child word. To useXPathSelectElementyou need to add the following using to your csharp file:There are obviously other tricks, ways and means depending on your needs. Good luck!