|
-
May 23rd, 2006, 01:20 AM
#1
Hyperactive Member
Re: Help Reading DataSet from XML
 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.
-
May 23rd, 2006, 09:41 AM
#2
Thread Starter
Addicted Member
Re: Help Reading DataSet from XML
I tried that already and it returns a blank string. Any other ideas?
-
May 23rd, 2006, 12:55 PM
#3
Hyperactive Member
Re: Help Reading DataSet from XML
 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.
-
May 23rd, 2006, 06:34 PM
#4
Thread Starter
Addicted Member
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")
""
-
May 23rd, 2006, 09:42 PM
#5
Thread Starter
Addicted Member
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"));
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|