I’m parsing and xml document with 66 or 67 attributes. I get these attributes into variables using the GetAttribute method. Most of the time the 67th attribute does not exist. I thought I’d handle this with a TRY block of code but it doesn’t error when the attribute does not exist. Why is that? It returns a “”. I would think it should error if an attribute does not exist?
Hi Duane,
Thanks for asking about this. I am not sure if you can do this, but can you supply example code that I can try? Feel free to use non-proprietary information so that I can try it out.
Sincerely,
Eugene
Except it is documented this way
http://documentation.xojo.com/index.php/XMLNode.GetAttribute
See Notes
Returns “” (empty string) if the attribute does not exist.
and this makes some sense
Maybe use GetAttributeNode instead which should give you a nil node which is easier to check
Thanks Norman. I did look at that but missed it in the Notes. This will work and now that I know it’s supposed to be that way I’m confident about it.
I’m parsing some XML where a true/false attribute is included in the return only if it false. So a test for the value will work for me. I’ll need to check the docs more closely.