When I receive XML data (via a Twitter API call, in this instance), I imagine it's best practice to somehow validate it before I begin working with it? My app has had a lot of untractable issues lately, and I want to rule out bad XML data.
Does XML ever go "bad" somehow? Would an overloaded server like Twitter's ever spit out just half of what should come my way?
My real question is twofold: should I validate XML data before I work with it, and how would I go about doing that? (I already know the supposed structure of the XML data)
Thanks!
One last clarification before I select an answer (and thanks for your efforts): If I only need 5 predictable fields out of the static-length XML file, does something like this leave loopholes that creating an XSD overcomes?
if(!isset($xml->id, $xml->text, $xml->created_at, $xml->sender, $xml->recipient)) throw...