Obtengo un nodo adicional en el archivo XML que debo eliminar. Puedo hacer esto simplemente usando XSLT o Map, aunque quiero lograrlo usando JavaScript. Quiero eliminar todo el nodo <Distributors> y <Location> del xml de entrada.
XML de entrada ,
<bookstore> <book category="cooking"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="children"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <Location>London</Location> <Year>2022</Year> <Distributors> <Distributor1>Ingram</Distributor1> <Distributor2>Amazon</Distributor2> <Distributor3>Company</Distributor3> </Distributors> </bookstore>Salida esperada xml
<bookstore> <book category="cooking"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="children"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <Year>2022</Year> </bookstore>Intenté usar DOM pero usar DOM consume mucha memoria debido al tamaño de los datos. ¿Hay alguna manera simple de lograrlo sin muchos recursos? De lo contrario, intentaré dividir el mensaje y luego lo verificaré.
var xmlDoc = xml.responseXML; var y = xmlDoc.getElementsByTagName("bookstore")[0]; var x = xmlDoc.documentElement.removeChild(y);Necesito sugerencias de expertos aquí.