JJKazJr Posted August 31, 2006 Posted August 31, 2006 Ok, I am fairly new to .net and do not know how to utilize all of the new features. I am at a point where I have to build a xml file based upon a schema. In the past I would just create nested loops to build the xml. With .Net there are new tools wich I will probably use although I am not sure what is best or if my expectations of them are reasonable so any guidence would be useful. xml writer...seems like the same way as I am used to but with different tags to help see what is going on. xml datadocument..not too sure how this works dataset...load in the schema creates multiple tables but I am unsure how to insert the related data. These are the things that I have been looking at. Suggestions about what path I should look into or a differnt way I should learn would be useful. I'm sure there are plenty of ways to do this I was just wondering what way was the best(fastest,easiest, most versitle). Thank you. Quote
Gill Bates Posted September 8, 2006 Posted September 8, 2006 XmlDocument is just a managed representation of the underlying textual xml. DataSets can have multiple DataTable instances. To add a row to a particular table you can just do:DataTable dt = myDataSet.Tables[0]; dt.Rows.Add(x,y,z);You might find the "GetXml()" method of the DataSet class useful. Quote
JJKazJr Posted September 8, 2006 Author Posted September 8, 2006 (edited) Yes, I know that I can add rows to a datatable as you have shown, I just don't know how to easily relate the all the data between the tables. Lets say I read an xml schema into a dataset, the structure it creates would be similar to: datatable[1] datatable[2] datatable[3] datatable.... when look at from the xml. Table 1's columns all corespond to the first elements and attributs, while the second would be the indented, sub categores, the third(subcatagores of the second) and so on. If I were to put data into datatable[3], is there an easy way to relate that back up to data already resideing in datatable[1] or would i have to work my way up, down the structure searching for the values of the relations and using them? That is what I was trying to get at. Thank you for the reply, I like all the input I can get, I just can't seem to get a lot at this forum. Edited September 8, 2006 by JJKazJr Quote
Administrators PlausiblyDamp Posted September 9, 2006 Administrators Posted September 9, 2006 If you are using a DataSet then you can add a DataRelation to it via the DataSet's Relations property - this will allow you to programatically navigate the relationship. If you have the .xsd that defines the schema then you can add this to your .Net project and VS will build a code model around the schema for you. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.