如何在 React Native 中将 XML 中的字符串写入变量?

How to write a string from XML to variable in React Native?

我有一个 XML 文件。我需要用 URL 导入它,因为它每天都会更新。我不明白如何在我的代码中导入它和使用它的信息。

我给你写个小例子

首先导入库

var XMLParser = require('react-xml-parser');

fetch()
.then(response => response.text())
.then(xmlText => (new XMLParser().parseFromString(xmlText)))
.then(data => console.log(data.getElementsByTagName('Name')))//or any other tag