Skip to content
Advertisement

How to update xml files in java

I have a xml file call data.xml like the code below. The project can run from client side no problem and it can read the xml file. The problem I have now is I I want to write a function that can update the startdate and enddate. I have no idea how to get start. Help will be appreciated.

JavaScript

my main.java

JavaScript

Advertisement

Answer

Start by loading the XML file…

JavaScript

Now, there are a few ways to do this, but simply, you can use the xpath API to find the nodes you want and update their content

JavaScript

Then save the Document back to the file…

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement