mydoghasworms Posted January 31, 2014 Share Posted January 31, 2014 I am parsing a piece of XML returned from a Web API. I am looking for a particular node. If that node does not exist, according to the MSXML documentation, it returns null. The problem is, I don't know how to check for null in AutoIT. I have read the online API doc for Null, but when I run the script using AutoIt3Wrapper v.2.1.2.9, it does not recognize null. Here is a sample script to show what I mean: $oXMLDOM = ObjCreate("Msxml2.DOMDocument.3.0") $xml = '<response><error code="1"><![CDATA[ Incorrect password or username ]]></error></response>' $oXMLDOM.loadXML($xml) $node = $oXMLDOM.selectSingleNode("/response/error") MsgBox(0, "", $node.text) ;; No problems $node = $oXMLDOM.selectSingleNode("/response/token") ;; $node should be 'null' now; how do I check that in AutoIT? MsgBox(0, "", $node.text) ;; Fails horribly Link to comment Share on other sites More sharing options...
Solution mydoghasworms Posted January 31, 2014 Author Solution Share Posted January 31, 2014 OK, well, I have kind of found a quick workaround for my problem. By using ObjName, I can check the name of the COM object returned, which is IXMLDOMElement if it is successful: If ObjName($node) = "IXMLDOMElement" Then MsgBox(0, "", "Success") Else MsgBox(0, "", "Failure") EndIf Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now