I have a class library project and in that project I have both xml file and class in which read data from that file.
So what code should write for it.
Thanks
Sandeep
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Oct 21, 2012, 11:19 PM EDT
if you want to convert xml to dataset
string path = "D:\\Santhosh\\XMLFile1.xml";
DataSet ds=new DataSet();
//Reading XML file and copying to dataset
ds.ReadXml(path);
If you want to convert xml to list of strings.
XDocument xDoc = XDocument.Load(new StringReader(xmlstr)); List modules = xDoc .Descendants("Module") .Select(n => n.Element("Name").Value) .ToList(); similarly you can modify it based on your custom classSandeep Singh ShekhawatRank #147 · 15.6K reputationPosted Oct 22, 2012, 12:56 AM EDT
And I want connection string in string variable from this. these are in class library.
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Oct 22, 2012, 1:00 AM EDT
then u can say
string str= ConfigurationManager.ConnectionStrings["con"].ToString();
and con is my connection string name
Check my article to know about more
http://www.c-sharpcorner.com/UploadFile/1a81c5/configuring-connection-string-in-app-config-file-during-runt/
VulpesRank #55 · 29.2K reputationPosted Oct 22, 2012, 1:19 AM EDT
For example, using LINQ to XML:
Sandeep Singh ShekhawatRank #147 · 15.6K reputationPosted Oct 22, 2012, 5:45 PM EDT
I am getting error when xml file load.
Could not find file 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\config.xml'.
So Where do I create this file ? Currently I have it in Root directory.
Thanks
Sandeep
VulpesRank #55 · 29.2K reputationPosted Oct 23, 2012, 5:43 AM EDT
As the current directory may not be where you think it is, I'd use the full path to the file in the XElement.Load method rather than just config.xml if that's what you're doing at present.