나는 네이티브 반응에 더 익숙하며 특히 요청을 가져 오는 데에 특히 익숙합니다. xml 파일로 응답하는 웹 서비스를 가져옵니다. 나는 그것을 분석하고 내가 원하는 값을 피커에 전달하려고 시도했지만 작동하지 않습니다! 요청에 대한 응답은 OK이지만 문제는 구문 분석에 있습니다. 나는이 오류가있을 때 변수 I 입력 querySelectorAll
, 같은 변수 doc
또는 s
을 사용하는 경우 parseSruface
에서xml api에서 요청 가져 오기 및 repsonse 구문 분석
parseSurface(s){
const DOMParser = require('xmldom').DOMParser;
console.log('Parsing the feed...');
let doc = new DOMParser().parseFromString(s, 'text/xml');
let objs = [];
let surfs = s.getElementsByTagName('Surfaces');
//let surfaces = doc.getElementsByTagName('surface:LIBELLE');
//let surfaces = s.querySelectorAll('Surfaces');
// let surface = s.querySelectorAll('surface');
// let libelle = s.querySelector('LIBELLE');
console.log(surfs)
}
getSurfaces(){
fetch('myWebService?')
.then((response) => response.text())
.then((responseText) => {
this.parseSurface(responseText);
})
.catch((err) => {
console.log('Error fetching the feed: ', err)
})
}
componentDidMount(){
this.getSurfaces();
}
: 나는 여기
이 내 코드의 ... 아무 일하지의 XMLDOM 라이브러리와 xml12js 시도getElementByTagName
또는
getElementByName
로 :
Error fetching the feed: [TypeError: doc.querySelectorAll is not a function. (In 'doc.querySelectorAll('Surfaces')', 'doc.querySelectorAll' is undefined)]
나는 완전히 잃었어요, 나는 분명 희망 나는 사전에, 덕분에 어떤 도움을 주셔서 감사합니다.
은'document' 개체가 웹 페이지의 표현이다. 당연히 React Native에는'document' 객체가 없습니다. – Dan