AutoitMike Posted March 21, 2013 Posted March 21, 2013 (edited) I have a simple function to open an xml file and read a node value. Every other time the function _XMLFileOpen() is encountered, I get "Com Error with DOM". This looks like a file close is not occuring, however, there is no file close function in the _XMLwrapper.au3 EG: #include <_XMLDOMWrapper.au3> #include <Array.au3> $Node="StartTime" $sXmlFile = "C:UsersMikeDocumentsreport.xml" $sXPath = "//ReportInfo/prop[@name='" & $Node & "']" _XMLFileOpen($sXmlFile) If @error Then MsgBox(0,"","error") EndIf $aRET = _XMLGetValue($sXPath) _ArrayDisplay($aRET, "") Even when encountering the error , the node value is still returned, obtained. The error code is 0000000 If I exit my program, restart it, no error is encountered the first time Any ideas???? Thanks Edited March 21, 2013 by AutoitMike
water Posted March 21, 2013 Posted March 21, 2013 Add a COM error handler to your script to get maximum information about what happened. Please have a look at ObjEvent in the help file for how to set up a COM error handler. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
AutoitMike Posted March 22, 2013 Author Posted March 22, 2013 I get the error trapped, all I can see is that it is error 000000 However, I noticed that once the file is open within a running script, I do not need to re open. However, I guess I need to keep track, set a flag that it is open???? There should be a function to test if it is open, or a function to close it. This is what the "Norm" seems to me after 40 + years of programming.
water Posted March 22, 2013 Posted March 22, 2013 What is the return value of _XMLFileOpen? I guess a handle to the file. So this is your flag that indicates that the file is open. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Lavonio Posted March 24, 2013 Posted March 24, 2013 Is there any way to close an open xml file? I made a script that needs to move the file to a new folder and since it was open, the move command did not work.
water Posted March 24, 2013 Posted March 24, 2013 (edited) Looks like you need to release Global variable $objDoc$objDoc = 0 Edited March 24, 2013 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Lavonio Posted May 7, 2013 Posted May 7, 2013 Thanks for the tip, but releasing $objDoc did not work ¿any other suggestions?
water Posted May 7, 2013 Posted May 7, 2013 I've never worked with XML myself but I remember there was another thread on this subject recently. Search the forum and you'll find what you need. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Lavonio Posted May 29, 2013 Posted May 29, 2013 Sorry for the delay, I had no time to test other options and was involved in other things. $objDoc = 0 indeed closes the file when it is open by the script, tested in another script and works fine. What I think is happening is that another application that I send the xml file to is locking it, so I can not move it. Solved this by moving the file first and then sending it to the application. Thanks for your help and time
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