Results 1 to 8 of 8

Thread: [RESOLVED] Help Reading DataSet from XML

Hybrid View

  1. #1
    Hyperactive Member umilmi81's Avatar
    Join Date
    Sep 2005
    Location
    Sterling Heights, Mi.
    Posts
    335

    Re: Help Reading DataSet from XML

    Quote Originally Posted by brandoom
    Thanks. I don't need a dataset, it was just an easy way to import the xml into a grid to see if it would help me visually.

    How do I reference the "gpm_cq" on the same line as your Console.Writeline?

    I tried pulling up all the intellisense properties on xMode and xMapType and I'm looking through the Locals window but I haven't figured it out yet.
    Code:
                XmlDocument xd = new XmlDocument();
                xd.Load(@"c:\temp\vbforums.xml");
    
                
                foreach (XmlElement xMode in xd.GetElementsByTagName("modes"))
                {
                    foreach(XmlElement xMapType in xMode.GetElementsByTagName("maptype"))
                    {
                        Console.WriteLine(xMapType.GetAttribute("players"));
                        Console.WriteLine(xMode.GetAttribute("type"));
                    }
                }
    Rate my post if it helped you.
    Last edited by umilmi81; May 23rd, 2006 at 01:23 AM.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Dec 2002
    Posts
    196

    Re: Help Reading DataSet from XML

    I tried that already and it returns a blank string. Any other ideas?
    Brandon S Davids

  3. #3
    Hyperactive Member umilmi81's Avatar
    Join Date
    Sep 2005
    Location
    Sterling Heights, Mi.
    Posts
    335

    Re: Help Reading DataSet from XML

    Quote Originally Posted by brandoom
    I tried that already and it returns a blank string. Any other ideas?
    It should work. Remember it's case sensitive. So "type" is different from "Type" is different from "TYPE". Check your XML again.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Dec 2002
    Posts
    196

    Re: Help Reading DataSet from XML

    Sorry but it doesn't work. I know it's case sensitive.

    Code:
    ? xMode.GetAttribute("type")
    ""
    ? xMode.GetAttribute("Type")
    ""
    ? xMode.GetAttribute("TYPE")
    ""
    Brandon S Davids

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Dec 2002
    Posts
    196

    Re: Help Reading DataSet from XML

    Problem Solved.

    Notice the top line needs to be "mode" NOT "modes".

    Thanks for helping me out on this one. I have my head wrapped around the xml now.

    Code:
    			foreach (XmlElement xMode in xd.GetElementsByTagName("mode"))
    			{
    				foreach(XmlElement xMapType in xMode.GetElementsByTagName("maptype"))
    				{
    					Console.WriteLine(xMapType.GetAttribute("players"));
    					Console.WriteLine(xMode.GetAttribute("type"));
    				}
    Brandon S Davids

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width