teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

調整

2021/12/22 02:45

投稿

yambejp
yambejp

スコア117923

answer CHANGED
@@ -1,9 +1,9 @@
1
+ fragmentを利用しようかと思ったのですが、普通にダミーのDOMを作るだけでいけそうですね
1
2
  ```javascript
2
3
  const xml='sample.xml';
3
4
  fetch(xml).then(res=>res.text()).then(txt=>{
4
5
  const xml=Object.assign(document.createElement('xml'),{innerHTML:txt});
5
- const tmp=[xml].reduce((x,y)=>(x.appendChild(y),x),new DocumentFragment());
6
- const ClientId=tmp.querySelector('xml').querySelector('RegisterClientResponse').getAttribute('ClientId');
6
+ const ClientId=xml.querySelector('RegisterClientResponse').getAttribute('ClientId');
7
7
  console.log(ClientId);
8
8
  });
9
9
  ```

1

ちょうせい

2021/12/22 02:45

投稿

yambejp
yambejp

スコア117923

answer CHANGED
@@ -1,4 +1,5 @@
1
1
  ```javascript
2
+ const xml='sample.xml';
2
3
  fetch(xml).then(res=>res.text()).then(txt=>{
3
4
  const xml=Object.assign(document.createElement('xml'),{innerHTML:txt});
4
5
  const tmp=[xml].reduce((x,y)=>(x.appendChild(y),x),new DocumentFragment());