Hey guys. I just started learning C# and I wanted to do an application to manage books (which book for which course and its cost, etc) and evaluation notes for each course as well (including some neat features I just thought of) and well I thought that for saving/loading files I could use an XML document for each user since I know C# has built-in support for XML reading. Ok so I've tried creating an object of XmlReader and it says it cannot be instanciated so I tried this and it just doesn't output anything at all. What's wrong ? Basically with this code I wanted to output everything in the file just to know if I was able to but what I want to read is a file formatted like this:
Code:<root> <course="Math"> <book> <author> amélie nothomb </author> <title> métaphysique des tubes </title> <isbn> </isbn> <price> 10.45 </price> </book> <evaluation> <title> recherche </title> <note> 70.3 </note> <max> 100.0 </max> <group> 65.4 </group> <weight> 20 </weight> </evaluation> </course> </root>Any idea/suggestion/comment is welcome and feel free to ask me any question if my question isn't too clear as I haven't built up vocabulary for C# yet. (I don't know the exact words).Code:using System; using System.IO; using System.Xml; class MyApp { public static void Main() { FileStream fs = new FileStream("test.xml", FileMode.Open); XmlReader xml_reader = new XmlTextReader(fs); while(!xml_reader.EOF) Console.WriteLine(xml_reader.ReadString()); Console.Read(); } }
Edit: It seems like the application isn't doing anything yet the only way to close the program is through CTRL + C.



LinkBack URL
About LinkBacks


