Link to home
Start Free TrialLog in
Avatar of scm0sml
scm0sml

asked on

problem deserialising an xml file

I have the following:
Private Function ConvertXMLToBDC(ByVal xmlPathFile As String) As BdcHandoffFile        
        Dim tmpBDC As New BdcHandoffFile
        Dim deSerialiser As XmlSerializer
        Dim xmlReader As New XmlTextReader(xmlPathFile)

        deSerialiser = New XmlSerializer(typeof(tmpBDC))        

        tmpBDC = deSerialiser.Deserialize(xmlReader)

        Return tmpBDC
    End Function

I'm literally just trying to deserialise an xml file into an object.

I'm getting the error 'Is' expected at the line:
        deSerialiser = New XmlSerializer(typeof(tmpBDC))
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

That is an example of mixing VB.NET and C# code:

 deSerialiser = New XmlSerializer(GetType(tmpBDC))

Bob
Avatar of scm0sml
scm0sml

ASKER

lol!!

ah soz.....im doing this for the first time and am ripping stuff of the net.

could you give a full vb.net example?
Example of what?

Bob
Avatar of scm0sml

ASKER

deserialising an xml file in vb.net 2.0
May I ask what the bigger picture is here?  What is using this functionality?

Bob
Avatar of scm0sml

ASKER

i will be receiving an object via a webservice.

at the moment tho i only have the serialised version of it in an xml file.

so i want to create the object using the xml so i can replicate receiving the object via the webservice and work with it from there.
So you have an object represented in an XML file, and you are trying to deserialize that object into a reference.

What is wrong with your code?  Are you getting exceptions?

Bob
Avatar of scm0sml

ASKER

Dim strDBname As String
        Dim oReg As Microsoft.Win32.RegistryKey
        oReg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Travelink\Configuration")
        strDBname = oReg.GetValue("TcatDatabase")

        Dim strQuoteID As String
        Dim _bdcImportFile As New BdcHandoffFile
        Dim _objTravelinkHandoff As New TravelinkHandoff
        '_bdcImportFile = ConvertXMLToBDC(_pathToExampleBDCFile)

        strQuoteID = CStr(_objTravelinkHandoff.CreateQuote(_bdcImportFile))

        MsgBox(strQuoteID)

gives me the error:
'Is' Expected

on line:
deSerialiser = New XmlSerializer(typeof(tmpBDC))        
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
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