G
Guest
The code below was coded to to take the xml that is sent to and from a Data
Object in our system and strip out any strange characters that may creap into
the xml that is received from a Mainframe system. The code works fine, except
that we noticed some data coruption happening in the system, and have
subsiquently confirmed that it was this peice of code.
The xml would just get corrupted. We had parameters called index that would
suddenly be named iindex. (Notice two i's) The coruption was totally random
though, and would occure in variuous places in the xml document.
I once had a similar situation using the a Byte array to ascii converter
also in the System.Text namespace that turned out to only convert the first
128 bytes and then wrapped for any byte values greater than this.
If anyone could shed some light on this I would seriously apreciate it.
Dim TempSreamReader As System.IO.StreamReader = New
System.IO.StreamReader(stmXML)
Dim TempString As New
System.Text.StringBuilder(TempSreamReader.ReadToEnd())
TempString = TempString.Replace("& ", "& ")
Dim FindValues() As Char =
System.Configuration.ConfigurationSettings.AppSettings("FindValues").ToCharArray()
Dim ReplaceValues() As Char =
System.Configuration.ConfigurationSettings.AppSettings("ReplValues").ToCharArray()
Dim c As Int32 = 0
For c = 0 To FindValues.Length - 1
TempString = TempString.Replace(FindValues(c),
ReplaceValues(c))
Next
stmXML.Position = 0
Dim TempStreamWriter As System.IO.StreamWriter = New
System.IO.StreamWriter(stmXML)
TempStreamWriter.Write(TempString.ToString())
stmXML.Position = 0
Object in our system and strip out any strange characters that may creap into
the xml that is received from a Mainframe system. The code works fine, except
that we noticed some data coruption happening in the system, and have
subsiquently confirmed that it was this peice of code.
The xml would just get corrupted. We had parameters called index that would
suddenly be named iindex. (Notice two i's) The coruption was totally random
though, and would occure in variuous places in the xml document.
I once had a similar situation using the a Byte array to ascii converter
also in the System.Text namespace that turned out to only convert the first
128 bytes and then wrapped for any byte values greater than this.
If anyone could shed some light on this I would seriously apreciate it.
Dim TempSreamReader As System.IO.StreamReader = New
System.IO.StreamReader(stmXML)
Dim TempString As New
System.Text.StringBuilder(TempSreamReader.ReadToEnd())
TempString = TempString.Replace("& ", "& ")
Dim FindValues() As Char =
System.Configuration.ConfigurationSettings.AppSettings("FindValues").ToCharArray()
Dim ReplaceValues() As Char =
System.Configuration.ConfigurationSettings.AppSettings("ReplValues").ToCharArray()
Dim c As Int32 = 0
For c = 0 To FindValues.Length - 1
TempString = TempString.Replace(FindValues(c),
ReplaceValues(c))
Next
stmXML.Position = 0
Dim TempStreamWriter As System.IO.StreamWriter = New
System.IO.StreamWriter(stmXML)
TempStreamWriter.Write(TempString.ToString())
stmXML.Position = 0