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

288
Views
XML How to save edited xml file

I want to select all elements that have attribut 'categoryId' equal 'VGA-NVD' and save them in new xml file. enter image description here

As you see here, products have attribut 'categoryId' and I want to take all of the elements that have in this attribut value "VGA-NVD".

I'm able to print them in console using java script:

<script> src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.0/FileSaver.min.js"></script>
<script src="https://requirejs.org/docs/release/2.3.5/minified/require.js"></script>  
<script>

    
    
    
    document.addEventListener('DOMContentLoaded', ()=>{
        
        let url = "cennik.xml";
        fetch(url)
        .then(response=>response.text())
        .then(data=>{
            
            let parser = new DOMParser();
            let xml = parser.parseFromString(data, "text/xml");
            let images = xml.getElementsByTagName('Image');
            let houses = xml.getElementsByTagName('Product');
            let remove = xml.querySelector('Categories');
            let remove2 = xml.querySelector('Producers');
            
            
            
            
            remove2.remove();
           
            for(let i=0; i<houses.length; i++){
            var url2 = images[i].getAttribute('url')   
            images[i].setAttribute('url','https://cdn.action.pl/File.aspx?CID=77353&UID=newpoint&PID=9c4b2df98fb7b4c6ec77ef13d552fba6&P='+url2)
            let houses_cat = houses[i].getAttribute('categoryId');
               if(houses_cat=="VGA-NVD"){
                    
               } 
            }
            
            console.log(xml)
            
            
        });
    })
    
    
   
</script>

This is the response: enter image description here

I called all of the elements that their 'categoryId' is equal 'VGA-NVD'. Now how to save this response to xml file. If it isn't possible in java script, what should I do? Thank you for help.

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!