I have parsed xml and I'm using querySelector
for example:
this.querySelector("TYPE").textContent
Sometimes value of this.querySelector("TYPE")
is null so previous line returns an error.
What is the most beautiful way to avoid errors?
I'm doing it with something like the following:
example = this.querySelector("TYPE") != null ? this.querySelector("TYPE").textContent : "" //UGLY!
But it is too long and looks bad.
Other way:
Own function like findInXml(this, "TYPE"),
but when I want to look deeper it's looks that:
findInXml(findInXml(this, "TYPE"), "STH") // UGLY!
I prefer to use it this way for example:
this.findXml("TYPE").findXml("STH") //Looks nice