Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 25th, 2006, 10:33 AM
Registered User
 
Join Date: May 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reading XML

I am trying to read in the following XML:

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?> 
- <weather>
  <timestamp zone="GMT">07/25/2006 11:27</timestamp> 
- <forecast>
  <citycode>CFV</citycode> 
- <day>
  <name>Tuesday</name> 
  <icon>02</icon> 
  <high unit="F">96</high> 
  <low unit="F">76</low> 
  <phrase>Mostly sunny</phrase> 
  </day>
- <day>
  <name>Wednesday</name> 
  <icon>03</icon> 
  <high unit="F">97</high> 
  <low unit="F">76</low> 
  <phrase>Partly sunny and hot</phrase> 
  </day>
- <day>
  <name>Thursday</name> 
  <icon>03</icon> 
  <high unit="F">94</high> 
  <low unit="F">73</low> 
  <phrase>Some sun</phrase> 
  </day>
- <day>
  <name>Friday</name> 
  <icon>03</icon> 
  <high unit="F">92</high> 
  <low unit="F">73</low> 
  <phrase>Partial sunshine</phrase> 
  </day>
- <day>
  <name>Saturday</name> 
  <icon>03</icon> 
  <high unit="F">93</high> 
  <low unit="F">70</low> 
  <phrase>Partly sunny</phrase> 
  </day>
- <day>
  <name>Sunday</name> 
  <icon>03</icon> 
  <high unit="F">97</high> 
  <low unit="F">71</low> 
  <phrase>Partly sunny</phrase> 
  </day>
- <day>
  <name>Monday</name> 
  <icon>02</icon> 
  <high unit="F">95</high> 
  <low unit="F">74</low> 
  <phrase>Mostly sunny</phrase> 
  </day>
  </forecast>
  <copyright>Copyright AccuWeather, Inc. 2006</copyright> 
  </weather>
I am able to get city code and then enter the child nodes. My problem arises that I cannot add the data to the database until I get the name field in as well. How would I pull the name text before I enter my loop? Here is what I have:

Code:
string xmlgroup = "";
                string locationID = "";
                string dayName = "";
                //Loop through all of the communities

                foreach (XmlNode node in SevenDay)
                {

                    if (node.ChildNodes.Count > 0)
                    {
                        XmlNodeList childnodes = node.ChildNodes;

                        foreach (XmlNode node2 in childnodes)
                        {

                            if (node2.ChildNodes.Count > 0)
                            {
                                //Set the child node list
                                XmlNodeList daychildnodes = node2.ChildNodes;

                                //Save all data to the databas

                                    locationID= node2.FirstChild.InnerText;
                                    Console.WriteLine("LocationID: "+locationID);

//I NEED TO GET THE dayname variable assigned here from the name field.
                            InjectSevenToDatabase(0, locationID, null, null, dayname);
                                foreach (XmlNode chNode in daychildnodes)
                                {
                                    InjectSevenToDatabase(1, locationID, chNode.Name, chNode.InnerText, dayname);
                                }
                            }
                        }
                    }
                }
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading XML through ASP jeffm_22 Classic ASP XML 3 June 11th, 2010 07:02 AM
problem reading a value from an xml mrjoka XML 14 June 8th, 2007 10:48 AM
reading a XML file connect2sandep XML 1 December 14th, 2006 04:50 AM
reading a XML file connect2sandep General .NET 0 December 13th, 2006 02:10 PM
Reading XML datastream realgone_ Classic ASP XML 5 September 22nd, 2004 01:17 PM



All times are GMT -4. The time now is 02:35 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.