Jump to content
Sign in to follow this  
AutoitMike

Com error with DOM

Recommended Posts

AutoitMike

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 by AutoitMike

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
AutoitMike

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.

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Lavonio

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.

Share this post


Link to post
Share on other sites
water

Looks like you need to release Global variable $objDoc

$objDoc = 0

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Lavonio

Thanks for the tip, but releasing $objDoc did not work

¿any other suggestions?

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Lavonio

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 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.