I have a program that inserts a new lesson to a course XML. Here is the XML file:
Course.xml
<Courses>
<Course>
<Name>ABC course</Name>
<Lessons>
<Lesson>
<Lesson_name>Learn ABC!</Lesson_name>
<Lesson_date>XX/XX/XXXX</Lesson_date>
</Lesson>
'WANT TO ADD A LESSON HERE!!!
</Lessons>
</Course>
<Course>
<Name>DEF Course</Name>
<Lesson>
<Lesson_name>Learn DEF!</Lesson_name>
<Lesson_date>XX/XX/XXXX</Lesson_date>
</Lesson>
</Course>
</Courses>
I would want to insert a lesson with all those nodes such as Lesson, Lesson_date, Lesson_name etc. without affecting the existing lessons and other elements. Is there any simple way?
Something like this should work:
If you want to modify the actual file, you could use
xmlDoc.Save()after that.