Hello I want to make the Xml dynamic, with a input form so a user can change it. After that save and make a new VERSION of the xml file. for now I have made a form that adds a new xml element, but i want to change the elements and make a new VERSION!
<?xml version="1.0" encoding="UTF-8"?>
<config version="2.1">
<general dryMode="true" logLevel="ERROR|WARNING|NOTICE|INFO|DEBUG">
</general>
<api
username="--username--"
password="--password--"
/>
</config>
Here is my Controller:
public function store(Request $request)
{
$xml = new \DOMDocument("1.0", "UTF-8");
$xml->load('editfile.xml');
$name = $_POST['name'];
$password = $_POST['password'];
//info user
$rootTag = $xml->getElementsByTagName("config")->item(0);
$infoTag = $xml->createElement("info");
$nameTag = $xml->createElement("name", $name);
$passwordTag = $xml->createElement("password", $password);
$infoTag->appendChild($nameTag);
$infoTag->appendChild($passwordTag);
$rootTag->appendChild($infoTag);
$xml->save('editfile.xml');
this works perfect but I want to be able to edite the exciting elements