I remember darkly that the XML class in AS3 would throw an exception if you tried to give it data in it's constructor that was not a valid XML string. But now I got a case where the XML happily takes every kind of data no matter it's valid XML or not...
var xml:XML;
try
{
xml = new XML("Some bogus string content.");
_valid = true;
}
catch (err:Error)
{
_valid = false;
}
... am I missing something??
Update: Qname somehow is null but somehow it's not, see here:
var qname:QName = xml.name();
if (!qname.localName)
{
_valid = false;
}
... throws an exception. Obvioulsy qname is null! But ...
var qname:QName = xml.name();
if (!qname || !qname.localName)
{
_valid = false;
}
... doesn't throw any exception. qname seems not to be null. WTH?
Your example should give XML object with no name and with nodeKind equal to "text". This is how text nodes are represented in XML. In addition to try/catch, you may check for name().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With