Accessing XML DOM child nodes by name

后端 未结 3 1973
萌比男神i
萌比男神i 2021-01-05 10:42

I want to access the textContent property of an XML object in JavaScript. The root item has several children which also have some children themselves. To get the children on

3条回答
  •  长发绾君心
    2021-01-05 11:31

    Using the following obtains the desired value of the child1 nodes for me..

    var k = xmlDoc.getElementsByTagName("child1");
    
    for(var i = 0; i < k.length; i++)
    {
      console.log(k[i].childNodes[0].nodeValue);
    }
    

提交回复
热议问题