XML Javascript parser issue

test [_nObjectives] .pool [j] .feedbackCorrect = oQuestions [j] .getElementsByTagName ("feedbackCorrect") [0] .firstChild.data;

and the XML in this case contains the following:

  <feedbackCorrect>
  </feedbackCorrect>

      

Running this line of code produces the following error: Message: Object Required

I do not understand. The tag is there, if it is empty, an error occurs and even has spaces, this does not work.

0


source to share


2 answers


you are getting error because

oQuestions[j].getElementsByTagName("feedbackCorrect")[0]

      

returns this tag and .firstChild returns null because it has no children ...



Are you sure you don't want

oQuestions[j].getElementsByTagName("feedbackCorrect")[0].data

      

?

+1


source


but why does it work when the xml looks like this:

<feedbackCorrect>any value</feedbackCorrect>

      



?

0


source







All Articles