Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i have xml file in my D:drive i want retrive xml file into windows applications and filter the xml data,
how can do this
if u know plz help me.
Posted
Comments
Sanjay K. Gupta 6-Dec-12 1:18am    
What you have tried so for?

Took this off : http://stackoverflow.com/questions/5604330/c-sharp-xml-parsing-read-a-simple-xml-file-and-retrieve-values[^]

View Link to read the sample xml, configure to code to suite your xml file

Read XML
C#
public void Read(string  fileName)
    {
        XDocument doc = XDocument.Load(fileName);

        foreach (XElement el in doc.Root.Elements())
        {
            Console.WriteLine("{0} {1}", el.Name, el.Attribute("id").Value);
            Console.WriteLine("  Attributes:");
            foreach (XAttribute attr in el.Attributes())
                Console.WriteLine("    {0}", attr);
            Console.WriteLine("  Elements:");

            foreach (XElement element in el.Elements())
                Console.WriteLine("    {0}: {1}", element.Name, element.Value);
        }
    }





To Open XML File in Hard Disk:

C#
static void Main()
    {
        var assembly = Assembly.GetExecutingAssembly();
        using (var stream = assembly.GetManifestResourceStream("ProjectName.test.xml"))
        using (var reader = new StreamReader(stream))
        {
            Console.WriteLine(reader.ReadToEnd());
        }
    }


Please vote if you found this usefull
 
Share this answer
 
v4
Take a look at this article. It shows how to read and write XML documents in Microsoft .NET using C# language.
Reading and Writing XML in C#[^]

Good luck.
 
Share this answer
 
Comments
Mohamed Mitwalli 4-Dec-12 6:13am    
5+
__TR__ 7-Dec-12 11:37am    
Thanks.
Wendelius 4-Dec-12 13:46pm    
Good tutorial, 5.
__TR__ 7-Dec-12 11:38am    
Thanks.
Have a look at XmlDocument[^] and especially XmlDocument.Load[^] method.
 
Share this answer
 
Comments
Mohamed Mitwalli 4-Dec-12 6:13am    
5+
Wendelius 4-Dec-12 13:46pm    
Thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900