Add Element inside of an element XML VB.NET



How can I add an element inside of another element. Im sure this is easy but I cant seem to find an answer in vb.net. I pretty much need a file that looks like:



<Crop>
<Name>CropName</Name>
<Field>
<Name>FieldName</Name>
<Expense>
<expense1></expense1>
<expense2></expense2>
</Expense>
</Field>
</Crop
<Crop>
<Name>CropName1</Name>
<Field>
<Name>FieldName</Name>
<Expense>
<expense1></expense1>
<expense2></expense2>
</Expense>
</Field>
</Crop


I also need help adding to this. So lets say I want to add to the crop called 'CropName1' and add another field element like I already have inside 'CropName1' then how would I do that in vb.net. I am open to use linq or whatever. Example code would be great help. Please don't give me a link to a tutorial on LINQ and xml. I know how XML works just not sure how to do this particular problem and thought I could get some sample code from you all. Thanks!


No comments:

Post a Comment