I'm trying to add users to xml file. I had with sucess the first user, but then I can't add more users.
I'm using the Dom libraries of PHP, the problem is that i can't write between the first tag "users"
This is how i read the file with the first user:
$doc = DOMDocument::load('./xml_files/teste2.xml');
$doc->saveXML();
$doc = new DOMDocument();
$doc->load('./xml_files/teste2.xml');
$doc->saveXML();
This is how I'm trying to getting the node <user>:
$r = $doc->getElementsByTagName('users')
but then, how can I add my new tag between the users???
XML FILE:
<?xml version="1.0" ?>
<users>
<user>
<username>aaaaa</username>
<password>aaaaa</password>
<first_name>aaaaa</first_name>
<last_name>bbbbb</last_name>
... (I want to add another user)...
</user>
</users>