Lately I've been teaching myself Linq, specifically Linq to XML, using whatever resources I can find on the interweb.
I'm having a hard time finding useful info on how to select a specific record from a xml file and then updating it.
This is how I created my XML document:
currentProject = new XDocument( new XDeclaration("1", "utf-8", "yes")); XElement Course = new XElement("Course", new XElement("CourseName", courseNameXML), new XElement("CourseDesc", courseDescXML), new XElement("ReqToTrain", courseReqTrainXML), new XElement("CourseStatus", courseStatusXML));
and this is the resulting xml: (Well, not really, some of the contents of this XML file has been created earlier using similar code)
<Projects> − <Project> <ProjectName>TestProject 1</ProjectName> <ProjectDesc>TestProject 1 Description</ProjectDesc> <ProjectStart>2008/05/19 01:13:01 PM</ProjectStart> <ProjectEnd>2008/08/21 01:13:17 PM</ProjectEnd> </Project> − <Course> <CourseName>Test Course 1</CourseName> <CourseDesc>Test Course 1 Description</CourseDesc> <ReqToTrain>20</ReqToTrain> </Course> − <Course> <CourseName>Test Course 2</CourseName> <CourseDesc>Test Course 2 description</CourseDesc> <ReqToTrain>10</ReqToTrain> </Course> − <Course> <CourseName>Test Course 3</CourseName> <CourseDesc>Test Course 3 Description</CourseDesc> <ReqToTrain>5</ReqToTrain> </Course> − <Venue> <VenueName>Test Venue 1</VenueName> <VenueCap>20</VenueCap> </Venue> − <Venue> <VenueName>Test Venue 2</VenueName> <VenueCap>10</VenueCap> </Venue> − <Venue> <VenueName>Test Venue 3</VenueName> <VenueCap>5</VenueCap> </Venue> </Projects>
I'm having a hard time figuring out how to select a specific <course> node, and its corresponding <ReqToTrain> node.
Any help will be greatly appreciated!
This is for a training logistics app. Basically it allows you to setup various training courses, the number of people required to train and course duration, then matches those training courses to training venues. The app divides the number of people requiring training with the selected venue capacity and works out how many days you require to complete your training course. After everything is setup, you can export your training schedule to Outlook.
Help me with this one little issue, and I will gladly post this entire app and it's source code as a tutorial here on DIC
"Edit"
Oops! I forgot to add, that at this stage, the XML document does not exists anywhere on the local file system, it is currently only in memory, and only gets created when the user decides to save the current "project"
This post has been edited by DrakenKorin: 19 May 2008 - 02:23 AM