Link to home
Start Free TrialLog in
Avatar of 1markmc
1markmcFlag for United States of America

asked on

XML Parser Error When attempting to open XML file with ADO object

I have a vbModule running in Access which attempts to "rehydrate" a recordset that has been persisted as an XML file.  The code has worked fine for several months on 20 or so windows 2000 computers and one XP computer.   It recently stopped working on the XP machine (the user and support personnel swear that no new software was installed before it quit working but I am not convinced - at any rate I don't have any control over that).  

I have limited access to the errant computer so when I get access to it I need to have high confidence that the fix I have in mind will work.

My question is:  What components need to be reinstalled to get the application running again?

Here are some specifics:

The exact error message is:
Persisted XML files cannot be opened with the version of the Microsoft XML Parser currently installed on this computer.  Upgrade your system through a windows 95/98 service release or Internet Explorer 5.0 or later.

The code that results in the error:

public function HydrateRecordset(ByVal strXDR as String) as ADODB.Recordset

    Dim stm as ADODB.Stream
   
    Set stm = New ADODB.Stream

    With stm
        .Open
        .WriteText strXDR
        .Position = 0
    End With

    Set HydrateRecordset = New ADODB.Recordset
    HydrateRecordset.Open stm  '<<ERROR HAPPENS HERE>>

End Function

The contents of the xml file were created using this function.

Public Function DehydrateRecordset (ByRef rst as ADODB.Recordset) as string
    Dim stm as ADODB.Stream
   
    Set stm = new ADODB.Stream
    rst.Save stm, adPersistXML
    stm.Position = 0
    DehydrateRecordset = stm.ReadText()

End Function

The program references Microsoft ActiveXData Objects 2.7 library
Avatar of leonstryker
leonstryker
Flag of United States of America image

You may need to switch to MDAC 2.5, since it is the last one which actually supports Jet.
Avatar of 1markmc

ASKER

Thanks for the comment.

However the code in question is not accessing the jet database it is only attempting to rehydrate a recordset that was ultimately created from SQL Server and then persisted as an XML file.
Yes, but "vbModule running in Access " may be the source of your problem
Avatar of 1markmc

ASKER

Good point.  However the code worked for several months prior to the recent issue and continues to work using MDAC 2.7 on Windows 2000 computers.
SOLUTION
Avatar of leonstryker
leonstryker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 1markmc

ASKER

Here is the contents of strXDR.  In this particular case it is a file that has just been created to store a recordset.  The error happens with this file anyway.  Also when trying to retrieve an existing recordset I get the same error -- as long as I am on the XP machine.

When I an existing xml file off the xp machine to another computer (in this case a win2000 machine) that same file works.  



<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
    xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
    xmlns:rs='urn:schemas-microsoft-com:rowset'
    xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
    <s:ElementType name='row' content='eltOnly' rs:CommandTimeout='30'
     rs:updatable='true' rs:ReshapeName='DSRowset1'>
        <s:AttributeType name='DatasourceGUID' rs:number='1'
             rs:nullable='true' rs:write='true' rs:calculation='00'>
            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='38'/>
        </s:AttributeType>
        <s:AttributeType name='ServerInstance' rs:number='2'
             rs:nullable='true' rs:write='true' rs:calculation='00'>
            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='40'/>
        </s:AttributeType>
        <s:AttributeType name='DatabaseName' rs:number='3' rs:nullable='true'
             rs:write='true' rs:calculation='00'>
            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='128'/>
        </s:AttributeType>
        <s:AttributeType name='NetworkProtocol' rs:number='4'
             rs:nullable='true' rs:write='true' rs:calculation='00'>
            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='20'/>
        </s:AttributeType>
        <s:AttributeType name='NetworkAddress' rs:number='5'
             rs:nullable='true' rs:write='true' rs:calculation='00'>
            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='128'/>
        </s:AttributeType>
        <s:AttributeType name='Packetsize' rs:number='6' rs:nullable='true'
             rs:write='true' rs:calculation='00'>
            <s:datatype dt:type='int' dt:maxLength='4' rs:fixedlength='true'/>
        </s:AttributeType>
        <s:AttributeType name='UserName' rs:number='7' rs:nullable='true'
             rs:write='true' rs:calculation='00'>
            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'/>
        </s:AttributeType>
        <s:AttributeType name='Password' rs:number='8' rs:nullable='true'
             rs:write='true' rs:calculation='00'>
            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'/>
        </s:AttributeType>
        <s:AttributeType name='ConnectionTimeout' rs:number='9'
             rs:nullable='true' rs:write='true' rs:calculation='00'>
            <s:datatype dt:type='int' dt:maxLength='4' rs:fixedlength='true'/>
        </s:AttributeType>
        <s:extends type='rs:rowbase'/>
    </s:ElementType>
</s:Schema>
<rs:data>
    <z:row DatasourceGUID='{2D84FBAC-E2B6-4DDF-BC69-4A0A559DBCC9}'/>
</rs:data>
</xml>

I do not believe that error message is generated by MSXML or MDAC, but rather it is a custom error message.

I realize this is a pain, but if you could modify your code or create a standalone program that includes error handling it may be a little easier to troubleshoot.  Something like (untested):

public function HydrateRecordset(ByVal strXDR as String) as ADODB.Recordset

    Dim stm as ADODB.Stream
   
    On Error GoTo ErrHandler

    'Try loading in an xml document first
    Dim XMLDoc As MSXML2.DOMDocument
    Set XMLDoc = New MSXML2.DOMDocument
    If Not XMLDoc.LoadXML strXDR
        MsgBox XMLDoc.ParseError.Reason
    End If
    Set XMLDoc = Nothing

    Set stm = New ADODB.Stream

    With stm
        .Open
        .WriteText strXDR
        .Position = 0
    End With

    Set HydrateRecordset = New ADODB.Recordset
    HydrateRecordset.Open stm  '<<ERROR HAPPENS HERE>>

    Exit Function
    ErrHandler:
    MsgBox Err.Description

End Function

Anthony
Avatar of 1markmc

ASKER

OK I found the answer.  

The user had DAO 3.0 installed and I uninstalled that.  I then reinstalled MDAC 2.7 and the application worked fine again.  

It appears that the message was indeed coming from the XML parser iteslf and was not a custom error message.  

Then please go ahead and close the question.  See here:
I answered my question myself. What do I do?
https://www.experts-exchange.com/help/closing.jsp#4

Thanks,
Anthony
Although, I do not think that this question falls into the "I answered my question myself." category.

Leon
Leon,

I don't either for a second, but my aim was to get this question closed and move on.

Anthony
True,

Leon
1markmc,

Thanks for the grade.

Leon