1

The below code works in IE but not in other browsers.

var node = xmlHttp.responseXML.documentElement;
var eitems = node.getElementsByTagName("nib:ProcessRequestResponse");
txt = eitems.context.text;
txt2 = txt.replace("\n", "");

Gives error "eitems.context is undefined". I have also tried eitems.context.textContent, eitems.context.innertext, eitems.context.innerHTML. All gives same error.

0

2 Answers 2

0

getElementsByTagName() returns a HTMLCollection. Access the first element with

 var item = eitems.item(0);

or just

 var item = eitems[0];

Use item to get the content.

4
  • eitems.item(0) gives null and eitems[0] gives undefined. I need the complete content of the tag "nib:ProcessRequestResponse". eitems.length displays 0 in both IE and other browsers. But eitems.context.text gives the content of the tag in IE where as in other browsers it gives "undefined".
    – Keertika
    Sep 16, 2021 at 15:12
  • What returns getElementsByTagName()? Sep 16, 2021 at 15:14
  • node.getElementsByTagName("nib:ProcessRequestResponse") returns [object HTMLCollection]
    – Keertika
    Sep 16, 2021 at 16:34
  • What is the output of console.log(JSON.stringify(Array.from(eitems)))? Sep 16, 2021 at 17:44
0

I used txt = node.textContent to get the content of tag and it worked

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Dec 16, 2021 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.