OracleClob to String conversion adds special characters.
607171Jul 13 2009 — edited Jul 21 2009Hi All,
I have this code in my C# project where I am getting a clob as output and converting into string.
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("p_XMLReport", OracleType.Clob).Direction = ParameterDirection.Output;
cmd.Parameters.Add("p_FilterConditions", OracleType.Clob).Value = conditionList;
cmd.Parameters.Add("p_ReportFields", OracleType.Clob).Value = fields;
cmd.ExecuteNonQuery();
OracleLob clob1 = ((OracleLob)cmd.Parameters["p_XMLReport"].Value).Value.ToString();
string _clob = System.Convert.ToString(clob1.Value);
The string that is returned is as below...There is a backslash introduced around the attribute names.
<DataSource>
<DataRow>
<column name = \"DEVELOPMENTSITE\">ADLK</column>
<column name = \"ID\">3</column>
<column name = \"PROJECTSTATUS\">Completed</column>
<column name = \"PROJECTTYPE\">New Wafer</column>
</DataRow>
</DataSource>
I further parse this string to add another attribute to each of the tags. I can successfully parse it and I see that the resultset has the attribute I wish to add.
However, when I try to save it, it throws "Illegal characters in path" error. I am thinking this is because of the blackslashes. Is there a way to get rid of them ??
resultset.LoadXml(_clob);
XmlNodeList list = resultset.SelectNodes("//DataSource/DataRow/column[@name = 'DEVELOPMENTSITE']");
foreach (XmlNode node in list)
{
XmlAttribute newAttr = resultset.CreateAttribute("label");
newAttr.Value = "Development Site";
node.Attributes.Append(newAttr);
}
resultset.Save(_clob);
Thanks,
AD