Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Post
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
0
Reply
modify the xml field data's using c#
johnsanthosh_tr
Jan 6 2005 6:30 AM
2.3k
Reply
Hi I have done aprogram in c# such that , my program reads a schema file and automatically loads data into a xml file. ex: consider the following schema
We can see that there are three fields namely billto_name, dividend and section. so my program reads this schema file and loads data automatically by obtaining the following xml file
Castle Hampers0
4.5
888888
Castle Hampers1
5.5
888889
Castle Hampers2
6.5
888888
Castle Hampers3
7.5
8888890
Castle Hampers4
8.5
888891
we can see the values Now my requirement is that I have another xml file with a single field name "billto_name". with some meaningful values. So I have to program such that if the schema contains a "billto_name" field then load those data's into the result xml.
ACCOUNTS CODES ONLY
ACCOUNTS CODES ONLY
AERIAL PRODUCT RANGE
AFL LICENCED PRODUCT
AUST RUGBY UNION
so the values such as AUST RUGBY UNION , AFL LICENCED PRODUCT EVERYTHING SHOUYLD BE INSERTED INTO THE PREVIOUS XML FILE FOR THAT FIELD ALONE. This is my requirement. I tried a lot but i couldnt suceed Here is my part of the coding. pls help me out to do this. private void button2_Click(object sender, System.EventArgs e) { dataSet1.ReadXmlSchema(txtSchema.Text); foreach (DataTable dTbl in dataSet1.Tables) { for(int j = 0; j <= 11; j++) { object[] oValues = new object[dTbl.Columns.Count]; int i = 0; string fileName = "C:\\CDEV\\testdatagenerator\\billtoname.xml"; XmlTextReader xtr = new XmlTextReader(fileName); foreach (DataColumn dColmn in dTbl.Columns) { try { xtr = new XmlTextReader("C:\\CDEV\\testdatagenerator\\billtoname.xml"); while(xtr.Read()) { switch (xtr.NodeType) { case XmlNodeType.Element: if((xtr.NodeType == XmlNodeType.Element) && (xtr.Name == "billto_name") ) { oValues[i] = xtr.Value; } break; } } } finally { if (xtr != null) { xtr.Close(); } } switch(dColmn.DataType.ToString()) { case "System.String": oValues[i] = (string) "sachin" + j; break; case "System.Int32": oValues[i] = (int) 100 + j; break; case "System.DateTime": oValues[i] = new DateTime(2004,01,30).AddDays(j * 1); break; case "System.Decimal": oValues[i] = new Decimal(10000900.99) + j; break; case "System.Int16": oValues[i] = (short) 32767 - j; break; case "System.Int64": oValues[i] = (long) 400 - j; break; case "System.Double": oValues[i] = (double) 888888 - j; break; case "System.Single": oValues[i] = (float) 4.5f + j; break; } } i = i+1; dTbl.Rows.Add(oValues); } } } private void button3_Click(object sender, System.EventArgs e) { dataSet1.WriteXml(txtXml.Text,XmlWriteMode.IgnoreSchema ); MessageBox.Show("Saved"); } Hope anyone will help me . santhosh
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
0
)
Next Recommended Forum
How to check the given string is float-point in c# ?
Datagrid as a lookup table