mansoor_aziz
December 4th, 2008, 04:41 AM
Hi,
I am reading XML from database using
ExecuteXMLReader()
and writing it to a file using
XmlTextWriter(filepath,encoding)
but the problem is that I am getting invalid character error ...
"hexadecimal value 0x03, is an invalid character. Line 3518, position 260."
is there any way to remove invalid characters from XML, I am creating XML in database using "for XML Explicit " and also using <![CDATA[]]> tags from all data.
here is my code
XmlReader XR ;
XmlTextWriter XW ;
XML = ""
cmd = new SqlCommand()
cmd.Connection = sqlConn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "sp_name"
cmd.Parameters.AddWithValue("@p1", p1)
cmd.Parameters.AddWithValue("@p2", p2)
cmd.CommandTimeout = 0
XR = cmd.ExecuteXmlReader()
XW = New XmlTextWriter(rootPath & fileName, System.Text.Encoding.UTF8)
XW.Formatting = Formatting.Indented
XW.WriteNode(XR, False)
Thanks and please help me out.
Best Regards
Mansoor Aziz
I am reading XML from database using
ExecuteXMLReader()
and writing it to a file using
XmlTextWriter(filepath,encoding)
but the problem is that I am getting invalid character error ...
"hexadecimal value 0x03, is an invalid character. Line 3518, position 260."
is there any way to remove invalid characters from XML, I am creating XML in database using "for XML Explicit " and also using <![CDATA[]]> tags from all data.
here is my code
XmlReader XR ;
XmlTextWriter XW ;
XML = ""
cmd = new SqlCommand()
cmd.Connection = sqlConn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "sp_name"
cmd.Parameters.AddWithValue("@p1", p1)
cmd.Parameters.AddWithValue("@p2", p2)
cmd.CommandTimeout = 0
XR = cmd.ExecuteXmlReader()
XW = New XmlTextWriter(rootPath & fileName, System.Text.Encoding.UTF8)
XW.Formatting = Formatting.Indented
XW.WriteNode(XR, False)
Thanks and please help me out.
Best Regards
Mansoor Aziz