Answer the question
In order to leave comments, you need to log in
Handling non-existent XML tag when parsing?
The following module is used for parsing: XMLDom
There is an xml-file that can contain the "SomeTag" tag.
It is necessary to check if there is a "SomeTag" tag in the code.
When using the code (there is no "SomeTag" tag in the xml file):
if(doc.documentElement.getElementsByTagName("SomeTag") == null) {
continue;
}
Answer the question
In order to leave comments, you need to log in
Gorily
Thank you for your reply.
Issue resolved.
To check if a tag exists, you can use:
if (doc.getElementsByTagName("SomeTag").length === 0) {
continue;
}
JS is not my profile, but judging by the text of the error, your doc or documentElement is null and you are trying to call a method on it (on null) that does not exist.
Thus, the question is not that getElementsByTagName is not looking for an element, but that you have not initiated something before, a simple query on the error text in Google also indicates this, here are similar problems with solutions:
stackoverflow.com/ questions/20641420/cannot-call-m...
https://developer.appcelerator.com/question/155648...
If you can't figure it out, show a larger piece of code.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question