Microsoft XMLDOM reads data is originally asynchronous by default!

xiaoxiao2021-03-06  17

Today, a very simple feature is to convert XML data with XSL. I have never been noted that XMLDOM gets data by default is asynchronous. Every time, LOAD is complete, TRANSFER is called directly after XML data. Because of the local debugging, no deployment on the web server, but today, it was discovered to report "The Data Necessary to Complete this Operation IS Not Yet Available." Depressed for a long time, I found that the data source used in Dom.Load (Datasrc) is low due to the low speed, and there is no LOAD before transfer. I checked a half a day, because Transfer is a DOM behind Load If there is no load, it will definitely do not perform conversion, and try to open these XML files directly on IE and a little problem with the XSL file. So I quickly checked MSDN and found that Async Property of A DomDocument was True by default. So the Load method is immediately returned immediately. At this time, it will have already completed the XML reads I need, causing the above error. depressed.

Later, put the TRANSFER's movements in the OnReadyStateChange event, and it is determined that readyState is equal to 4 before starting conversion. Finally got a problem.

Feeling: Basic knowledge is not solid, don't understand what you have used!

转载请注明原文地址:https://www.9cbs.com/read-45389.html

New Post(0)