Avatar of myjobiscoding
myjobiscoding
 asked on

java - add an element to XML documnet

I know how to remove the element using xpath like below, but dont know how to add an new element. Please advise

For example, I use the following to remove the element using xpath
elem = getElements("./student:enrolment", std);
elem.detach();

Now I want to add the enrolled course to the element <./student:enrolment", std);
i want to add the following element

<std1:enrollendCourse>
      <std1:course>Law</std1:course>
</std1:enrollendCourse>



please advise
Java

Avatar of undefined
Last Comment
Manikandan Thiagarajan

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Manikandan Thiagarajan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes