I have been told I must use serialization.
I generated an XSD from the file I am using for input. From the XSD, I created the VB class using XSD.EXE for the incoming XML.
I added the required record and tag for the filename and changed the name of the root record and created a second VB class for the outgoing XML.
I added the VB class for the incoming and outgoing XML to my project.
To deserialize and serialize the XML, I found the code here:
http://www.dreaminco...ation-in-vbnet/
I assume the first thing I need to do is Deserialize the XML file. To try to use the code, I put the following in my programme to read the incoming XML file:
s_text = XML_CONTROL.FromXml(l_s_SourcePath & l_s_Srcfilename, GetType(Envelope))
l_s_SourcePath is the full path of the folder containing the file
l_s_Srcfilename is the name of the file
Envelope is the root record of the incoming XSD
I get an error on the following line from the XML_CONTROL class:
obj = ser.Deserialize(xmlReader)
eException.Message "There is an error in XML document (1, 1)." String
Following the function line by line
Dim ser As XmlSerializer
ser = New XmlSerializer(ObjType)
Dim stringReader As StringReader
stringReader = New StringReader(Xml) ‘XML is filename including full path
Dim xmlReader As XmlTextReader
xmlReader = New XmlTextReader(stringReader) ‘stringreader is {System.IO.StringReader}
Dim obj As Object
obj = ser.Deserialize(xmlReader) ‘xmlReader is {System.Xml.XmlTextReader}
I think that once I get to the obj = ser.Deserialize line that xmlReader should have the contents of the file, but when I do a watch on:
xmlReader.Item(0).ToString
I get the ArgumentOutOfRange exception.
Any suggestions as to where I go from here?

New Topic/Question
Reply




MultiQuote



|