4

How to read xml file from windows form application in c#? I am new in this .net framework prograaming. I have 3.5 .net framework please give simple program for it

4
  • @mangesh - can you rewrite your question with a little bit more information about what you are trying to achieve. As it stands now you're not going to get any answers and are likely to be down-voted. Commented Sep 13, 2009 at 17:19
  • Not to mention, even my 3 year old knows down cold that when you ask for something, you say "Please", not just "give". Commented Sep 13, 2009 at 17:26
  • 3
    @DVK: your 3 year old is presumably a native English speaker, which isn't true of everyone on the planet. Commented Sep 13, 2009 at 17:32
  • 1
    (1) My kid is actually NOT a native English speaker, nor am I. (2) Every language on the planet that I'm aware of has a "please" equivalent. I'd be very glad if you provided counter-example before adding snide "I'm a sensitive multiculturalist and you're not" remarks. (3) It's one of the very first words people learn when learning English, which the questioner obviously knows to some extent. (4) I wasn't commenting on quality of grammar, but on level of politeness. Commented Sep 14, 2009 at 1:43

2 Answers 2

5

The simplest way to read an XML file into memory is to use the XDocument.Load method. This method takes a file path and returns an XDocument instance which can be used to query the contents

XDocument doc = XDocument.Load(@"c:\path\to\the\xmlfile.xml");

If you're working with an older API, you may need to use the XmlDocument class. It can be loaded in the following way

XmlDocument doc = new XmlDocument();
doc.Load(@"c:\path\to\the\xmlfile.xml");
Sign up to request clarification or add additional context in comments.

Comments

2

If you're using .Net 3.5 or later, you can use the XDocument class to read and write XML.

If you're still in .Net 2.0, you can use the XmlDocument class.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.