STEP 1: Declare XmlDocument and following Element and AppendClild in Document
XmlDocument docConfig = new XmlDocument();
XmlNode xmlNode = docConfig.CreateNode(XmlNodeType.XmlDeclaration, "", "");
XmlElement rootElement = docConfig.CreateElement("SCHEDULES");
docConfig.AppendChild(rootElement);
STEP 2:Call the function that we created to append multiple element in XmlDocument by putting this function in loop
{
This.Create_XML(docConfig,CLASS_TIMING_ID,DAY_DATE,DAY_NAME,FACULTY_ID,SUBJECT_ID)
}
STEP3 : The Code Convert XmlDocument into SQLXml and you can pass into Procedure and with help to Cursor you can inserted into procedure
StringWriter sw = new StringWriter();
XmlTextWriter tx = new XmlTextWriter(sw);
docConfig.WriteTo(tx);
StringReader transactionXml = new StringReader(sw.ToString());
XmlTextReader xmlReader = new XmlTextReader(transactionXml);
SqlXml sqlXml = new SqlXml(xmlReader);
STEP 4: call fuction and pass the SqlXml Object like this
--------------------------------------------function that you calling aboub---------------------------------------------------------------------------
private void Create_XML(XmlDocument docConfig, string CLASS_TIMING_ID, string DAY_DATE, string DAY_NAME,string FACULTY_ID,string SUBJECT_ID)
{
XmlElement hedder = docConfig.CreateElement("SCHEDULE");
docConfig.DocumentElement.PrependChild(hedder);
docConfig.ChildNodes.Item(0).AppendChild(hedder);
// Create <installationid> Node
XmlElement environmentElement = docConfig.CreateElement("CLASS_TIMING_ID");
XmlText environText = docConfig.CreateTextNode(CLASS_TIMING_ID);
environmentElement.AppendChild(environText);
hedder.PrependChild(environmentElement);
// Create <environment> Node
XmlElement environmentElement0 = docConfig.CreateElement("DAY_DATE");
XmlText environText0 = docConfig.CreateTextNode(DAY_DATE);
environmentElement0.AppendChild(environText0);
hedder.PrependChild(environmentElement0);
// Create <environment> Node
XmlElement environmentElement1 = docConfig.CreateElement("DAY_NAME");
XmlText environText1 = docConfig.CreateTextNode(DAY_NAME);
environmentElement1.AppendChild(environText1);
hedder.PrependChild(environmentElement1);
// Create <environment> Node
XmlElement environmentElement4 = docConfig.CreateElement("FACULTY_ID");
XmlText environText4 = docConfig.CreateTextNode(FACULTY_ID);
environmentElement4.AppendChild(environText4);
hedder.PrependChild(environmentElement4);
// Create <environment> Node
XmlElement environmentElement6 = docConfig.CreateElement("SUBJECT_ID");
XmlText environText6 = docConfig.CreateTextNode(SUBJECT_ID);
environmentElement6.AppendChild(environText6);
hedder.PrependChild(environmentElement6);
}
No comments:
Post a Comment