Here is the code, basically it opens up the xml file, finds some text, and changes the text. Then converts it to Hex and inserts it into the database (the xml files are stored as blobs in a database)
if (rdr.HasRows)
{
rdr.Read();
xmlText = System.Text.Encoding.ASCII
string[] separators = { "<my:Status>", "</my:Status>" };
// result contains the status text
string[] result = xmlText.Split(separators, StringSplitOptions.RemoveE
statusTxt = result[1];
// replace the status text with closed
xmlTextClosed = xmlText.Replace(statusTxt,
// next insert the xml back into db
//open conn
//SqlConnection connS2 = new SqlConnection(connectionIn
connS2.Open();
Encoding encoding = Encoding.GetEncoding("IBM4
byte[] bytestxt = encoding.GetBytes(xmlTextC
//convert to Hex
string bytesStr = "0x" + BitConverter.ToString(byte
string sqlInsert = "UPDATE TABLE SET FIELD = " + bytesStr + " WHERE FIELDNAME ='ECR" + ecrFilename + ".xml'";
SqlCommand insCmd = null;
insCmd = new SqlCommand(sqlInsert, connS2);
insCmd.ExecuteNonQuery();
}
But the last 6 characters are missing from the XML file. Is it anything to do with my array size? I would post some XML but the xml file is huge.
The XML ends like this: </my:Fields>
But for some the xml looks like this at the end: </my:Fi
i.e. the "ields>" is missing from the end of the xml file.
Hoep this makes sense
Main Topics
Browse All Topics





by: JimBrandleyPosted on 2008-11-26 at 15:28:37ID: 23046768
Can you please post an example of the XML that's failing, and the code you are running to do the conversion?
Jim