<script>

var xhr = new XMLHttpRequest();
xhr.open('GET', 'xml.php');
xhr.send();
xhr.onreadystatechange = function () {
if (this.readyState !== 4) return;
// this.responseXML 专门用于获取服务端返回的 XML 数据,操作方式就是通过 DOM 的方式操作
// 但是需要服务端响应头中的 Content-Type 必须是 application/xml
console.log(this.responseXML.documentElement.children[0].innerHTML);
console.log(this.responseXML.documentElement.getElementsByTagName('name')[0])
}

</script>

相关文章:

  • 2022-12-23
  • 2021-06-22
  • 2021-11-29
  • 2021-06-14
  • 2022-12-23
  • 2021-06-08
猜你喜欢
  • 2021-11-25
  • 2021-10-06
  • 2021-12-04
  • 2022-12-23
  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案