admin管理员组

文章数量:1277372

I'm having XML file I want to read and modify XML data using JavaScript, this is my XML data:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<figlist>
  <figgroup name="Circuit Diagram">
    <category  id="A">
      <name>A GENERAL INFORMATION</name>
      <subcategory name="GI  GENERAL INFORMATION">
        <fig id="jtawa5397gb">
          <name>CONSULT CHECKING SYSTEM</name>
          <svgfile>jtawa5397gb.svg</svgfile>
        </fig>
      </subcategory>
    </category >

In this XML data CONSULT CHECKING SYSTEM I want to modify what ever contents inside tag by reading csv file data

For example in CSV file data it will have

CONSULT CHECKING SYSTEM CONSULTAR EL SISTEMA DE CONTROL

like this contents inside the tag it should change according Csv file data, I need to your help to modify this content through JavaScript.

I'm having XML file I want to read and modify XML data using JavaScript, this is my XML data:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<figlist>
  <figgroup name="Circuit Diagram">
    <category  id="A">
      <name>A GENERAL INFORMATION</name>
      <subcategory name="GI  GENERAL INFORMATION">
        <fig id="jtawa5397gb">
          <name>CONSULT CHECKING SYSTEM</name>
          <svgfile>jtawa5397gb.svg</svgfile>
        </fig>
      </subcategory>
    </category >

In this XML data CONSULT CHECKING SYSTEM I want to modify what ever contents inside tag by reading csv file data

For example in CSV file data it will have

CONSULT CHECKING SYSTEM CONSULTAR EL SISTEMA DE CONTROL

like this contents inside the tag it should change according Csv file data, I need to your help to modify this content through JavaScript.

Share Improve this question edited Dec 1, 2023 at 18:43 nullromo 2,6473 gold badges23 silver badges50 bronze badges asked Jan 22, 2017 at 4:45 yuvarajyuvaraj 951 gold badge3 silver badges9 bronze badges 1
  • 1 Possible duplicate of Cross-Browser Javascript XML Parsing – luiscrjr Commented Jan 22, 2017 at 5:04
Add a ment  | 

1 Answer 1

Reset to default 6

If you are using the JavaScript environment of a modern web browser, you can manipulate XML data as I explained here: Create XML in Javascript

If not, I remend to use another XML DOM implementation for JavaScript, for example xmldom.

Let's suppose, xmlDoc is your XML document as an XML DOM object. To change the text CONSULT CHECKING SYSTEM to CONSULT CHECKING SYSTEM CONSULTAR EL SISTEMA DE CONTROL, you could retrieve the element node like this:

var name = xmlDoc.getElementsByTagName("name")[1];

and change the content like this:

name.textContent = "CONSULT CHECKING SYSTEM CONSULTAR EL SISTEMA DE CONTROL";

本文标签: Read and modify XML data using JavaScriptStack Overflow