Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

284
Views
No se puede agregar el elemento secundario más de una vez con el nodo principal en XML (Javascript)

Buenos días,

Tengo dificultades para agregar un parentNode específico, por lo que básicamente cada vez que llamo dos veces al parentNode con appendChild, solo ejecuta el primer código appendChild. Sin embargo, necesito que funcionen juntos. Creé el mismo elemento dos veces pero también con diferentes nombres de variables. No estoy seguro de lo que está mal con eso ... ¡ayuda, gracias!

Ahora mismo solo hace esto..

 <gmd:ParentNode> <gmd:onLine> <gmd:CI_OnlineResource> Partial Download Test </gmd:CI_OnlineResource> </gmd:onLine> </gmd:ParentNode>

no puedo llegar a esto..

 <gmd:ParentNode> <gmd:onLine> <gmd:CI_OnlineResource> Partial Download Test </gmd:CI_OnlineResource> </gmd:onLine> <gmd:onLine> <gmd:CI_OnlineResource> Full Download Test </gmd:CI_OnlineResource> </gmd:onLine> </gmd:ParentNode>

Aquí está mi código para referencia

 function test(){ xmlString = this.item.sys_xml_clob; var metadataXmlString = jQuery.parseXML(xmlString); //Parent Node let newParentNode = metadataXmlString.getElementsByTagName("gmd:ParentNode") //Creation of the Nodes let newNode = metadataXmlString.createElement("gmd:onLine") let newNode2 = metadataXmlString.createElement("gmd:CI_OnlineResource") let partialDownload = metadataXmlString.createTextNode("Partial Download Test") let oldNode = metadataXmlString.createElement("gmd:onLine") let oldNode2 = metadataXmlString.createElement("gmd:CI_OnlineResource") let fullDownload = metadataXmlString.createTextNode("Full Download Test") //First Node to be Appended newNode2.appendChild(partialDownload) newNode.appendChild(newNode2) newParentNode[0].appendChild(newNode) //Second Node to be Appended oldNode2.appendChild(fullDownload) oldNode.appendChild(oldNode2) newParentNode[0].appendChild(oldNode) xmlString = (new XMLSerializer()).serializeToString(metadataXmlString); console.log(xmlString) }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!