Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 handling XML STRING in C# Code

Author  Topic 

bluestar
Posting Yak Master

133 Posts

Posted - 2008-10-07 : 11:26:57
please help me in this,
My stored procedure is working fine,

in my C# code this xml string is generated which is <xmlList><xl>1</xl><xl>i</xl><xl>2</xl><xl>ii</xl><xmlList>,

but my SP is excepting this string


<xmlList><xl value="1"></xl><xl value="i"></xl></xmlList><xmlList><xl value="12123"></xl><xl value="ifqewferf"></xl></xmlList>

please help me how shall I modify my C# code in order to get xml string in this form

<xmlList><xl value="1"></xl><xl value="i"></xl></xmlList><xmlList><xl value="12123"></xl><xl value="ifqewferf"></xl></xmlList>


this is my C# code

protected void btnsubmit_Click(object sender, EventArgs e) {

int schemaid;

schemaid = tocheaderstyle.InsertTOCNumberingSchema(txtname.Text);

String xmlList = GetList();

tocheaderstyle.InsertTOCCounterStyle(schemaid,xmlList);



}
private String GetList() {
XmlDocument doc = new XmlDocument();
XmlElement elem = doc.CreateElement("xmlList");
doc.AppendChild(elem);

XmlElement root = doc.DocumentElement;
for (int i = 0; i < dgItem.Rows.Count; i++)
{
XmlElement infoEle = doc.CreateElement("xl");
XmlElement infoEle1 = doc.CreateElement("xl");

DataRowView drv = (DataRowView)dgItem.Rows[i].DataItem;
TextBox tb = (TextBox)dgItem.Rows[i].FindControl("txtdrgno");
TextBox tb1 = (TextBox)dgItem.Rows[i].FindControl("txtdrgno1");
if((tb.Text != "") && (tb1.Text != ""))
{
//infoEle.SetAttribute("TOCHSCounterNumber", TOCHSCounterNumber);
infoEle.InnerText = tb.Text;
root.AppendChild(infoEle);
//infoEle.SetAttribute("TOCHSCounterLabelText", TOCHSCounterLabelText);
infoEle1.InnerText = tb1.Text;
root.AppendChild(infoEle1);
//infoEle.InnerText = tb.Text;
//infoEle1.InnerText = tb1.Text;
}
}
string s = doc.InnerXml;
return s;
}

please do reply

thank you

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-10-07 : 12:37:59
use XmlDocument.CreateAttribute for creating attributes.

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.1 out!
Go to Top of Page
   

- Advertisement -