不支持 React Native JayData XML DOM 解析器
React Native JayData XML DOM parser not supported
我是 javascript 和 react-native 的新手,我正在尝试构建一个使用 oData 的客户端。通过尝试执行 jayDatas 函数 initService,我收到以下错误消息:
{ message: 'XML DOM parser not supported',
srcText: '',
errorXmlText: '',
request:
{ requestUri: 'https://my322506.sapbydesign.com/sap/byd/odata/cust/v1/demoapp/$metadata',
method: 'GET',
headers:
{ Authorization: 'Basic Y2dyOjF6M2k3bU05',
Accept: 'application/xml',
'OData-MaxVersion': '4.0' },
recognizeDates: false,
callbackParameterName: '$callback',
formatQueryString: '$format=json',
enableJsonpCallback: false,
async: true },
response:
{ requestUri: 'https://my322506.sapbydesign.com/sap/byd/odata/cust/v1/demoapp/$metadata',
statusCode: 200,
statusText: undefined,
headers:
[ 'c4c-odata-response-time': '691 ms',
dataserviceversion: '1.0',
'Content-Type': 'application/xml' ],
...
Possible Unhandled Promise Rejection (id: 0):
XML DOM parser not supported`
我的代码:
jayData
.initService('https://my322506.sapbydesign.com/sap/byd/odata/cust/v1/demoapp/', credentials)
.then(function (remoteDB, contextFactory, contexType) {
console.log('HELLO');
});
错误来自文件jaydata-odatajs\lib\xml.js Line 190
代码:
function xmlParse(text) {
var domParser = undefined;
if (utils.inBrowser()) {
domParser = window.DOMParser && new window.DOMParser();
} else {
domParser = new (require('xmldom').DOMParser)();
}
var dom;
if (!domParser) {
dom = msXmlParse(text);
if (!dom) {
xmlThrowParserError("XML DOM parser not supported0");
}
return dom;
}
好的,我修好了。
JayData 表示我们在浏览器中并尝试从 window 中获取解析器,但 window 中没有解析器。
所以我只是在 window 中设置了 DOMParser 并且它起作用了。
export default class AwesomeProject extends Component {
constructor(props)
{
super(props);
window.DOMParser = require('xmldom').DOMParser;
谢谢!
我是 javascript 和 react-native 的新手,我正在尝试构建一个使用 oData 的客户端。通过尝试执行 jayDatas 函数 initService,我收到以下错误消息:
{ message: 'XML DOM parser not supported',
srcText: '',
errorXmlText: '',
request:
{ requestUri: 'https://my322506.sapbydesign.com/sap/byd/odata/cust/v1/demoapp/$metadata',
method: 'GET',
headers:
{ Authorization: 'Basic Y2dyOjF6M2k3bU05',
Accept: 'application/xml',
'OData-MaxVersion': '4.0' },
recognizeDates: false,
callbackParameterName: '$callback',
formatQueryString: '$format=json',
enableJsonpCallback: false,
async: true },
response:
{ requestUri: 'https://my322506.sapbydesign.com/sap/byd/odata/cust/v1/demoapp/$metadata',
statusCode: 200,
statusText: undefined,
headers:
[ 'c4c-odata-response-time': '691 ms',
dataserviceversion: '1.0',
'Content-Type': 'application/xml' ],
...
Possible Unhandled Promise Rejection (id: 0):
XML DOM parser not supported`
我的代码:
jayData
.initService('https://my322506.sapbydesign.com/sap/byd/odata/cust/v1/demoapp/', credentials)
.then(function (remoteDB, contextFactory, contexType) {
console.log('HELLO');
});
错误来自文件jaydata-odatajs\lib\xml.js Line 190 代码:
function xmlParse(text) {
var domParser = undefined;
if (utils.inBrowser()) {
domParser = window.DOMParser && new window.DOMParser();
} else {
domParser = new (require('xmldom').DOMParser)();
}
var dom;
if (!domParser) {
dom = msXmlParse(text);
if (!dom) {
xmlThrowParserError("XML DOM parser not supported0");
}
return dom;
}
好的,我修好了。 JayData 表示我们在浏览器中并尝试从 window 中获取解析器,但 window 中没有解析器。 所以我只是在 window 中设置了 DOMParser 并且它起作用了。
export default class AwesomeProject extends Component {
constructor(props)
{
super(props);
window.DOMParser = require('xmldom').DOMParser;
谢谢!