0
I have an xml document, a script.js and an html page where the following test should occur,I click on a button on the page and a function should be executed in the script that removes a group of nodes from the xml file,follow it below
FILE.XML
<?xml version="1.0" encoding="utf-8"?>
<filmes>
<filme>
<titulo>A Casa Branca</titulo>
<genero>comédia</genero>
<ano>1999</ano>
<faixaEtaria>+10</faixaEtaria>
</filme>
<filme>
<titulo>A casa monstro</titulo>
<genero>animação</genero>
<ano>2007</ano>
<faixaEtaria>+10</faixaEtaria>
</filme>
<filme>
<titulo>O grito</titulo>
<genero>terror/suspense</genero>
<ano>2003</ano>
<faixaEtaria>+14</faixaEtaria>
</filme>
<filme>
<titulo>Pânico</titulo>
<genero>suspense</genero>
<ano>2006</ano>
<faixaEtaria>+14</faixaEtaria>
</filme>
</filmes>
And when I click on the page button,it should remove the first group of nodes from the movie node,consequently the code will look like this
<?xml version="1.0" encoding="utf-8"?>
<filmes>
<titulo>A casa monstro</titulo>
<genero>animação</genero>
<ano>2007</ano>
<faixaEtaria>+10</faixaEtaria>
</filme>
<filme>
<titulo>O grito</titulo>
<genero>terror/suspense</genero>
<ano>2003</ano>
<faixaEtaria>+14</faixaEtaria>
</filme>
<filme>
<titulo>Pânico</titulo>
<genero>suspense</genero>
<ano>2006</ano>
<faixaEtaria>+14</faixaEtaria>
</filme>
</filmes>
I’ve researched about removeChild but I can’t create a function that removes the nodes from the xml file, I really need help because I can’t find solutions for this,so any example of function that solves the problem will be very useful.
Do you want to remove from the file or read? I mean, rewrite the file without the node or just read and remove the node?
– Sam
of the file, it serves as a data store in my project
– Luan Rodrigues
that is, rewrite the file without the node
– Luan Rodrigues
Vc uses PHP?......
– Sam
use, however I am creating a hybrid mobile app and need to use JS functions, the app will fetch data from xml file.
– Luan Rodrigues
To rewrite the vc file you need to use a server-side language such as PHP.
– Sam
OK,but what about with JSON? It is possible for me to change and remove values in json code with javascript?
– Luan Rodrigues
Yes, it is possible.
– Sam
Got it, thank you.
– Luan Rodrigues