I am required to fetch data from a "URL" link provided by client for different time periods (date parameters are passed to the URL link).
The links returns a "XML".
I use this link to to load the XML in XML document
e.g: XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("https://some_url");
The XML gets loaded in XML document without any error
I convert this XML into string and send it to my stored procedure to enter data in table.
I have used sp_xml_preparedocument and OPENXML in my stored procedure
But when I pass this XML string to my SQL stored procedure, I am getting an error 'An invalid character was found in text content'. Could not find prepared statement with handle 1 with description "The XML parse error 0xc00ce508 occurred on line number 1"
My code to convert XML to string and save to Database is is:
StringWriter stringWriter = ConvertToStringFormat(xmlDoc);
SaveMedDBaseRecordsToDB(stringWriter.ToString());
public static StringWriter ConvertToStringFormat(XmlDocument xmlDoc)
{
StringWriter stringWriter = new StringWriter();
XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter);
xmlDoc.WriteTo(xmlTextWriter);
return stringWriter;
}
I am trying to get rid of this issue from past 3 days.
Please anyone help me to deal with this issue as I need to import the data as early as possible.
Thanx in advanced
User contributions licensed under CC BY-SA 3.0