Need a little C#.NET/XML reading Help

2 replies
I don't know how many novice programmers there are here but I have a pretty tough question. I've been trying to figure it out for a while now. I'm looping through ever member I have and for each member I am looping through all 5 of their events. In addition as I'm looping I am reading their "EventClosed" node in each xml file. If the string returns "closed" it should change the xml transform source. But for some reason it isn't reading the node. I'm thinking maybe because I call close on the first loop and the name is never changed so it stays closed but idk... Any ideas?

Code:
        public void ListUsers(MembershipUserCollection users)
        {
            foreach (MembershipUser u in users)
            {
                int i = 1;

                while (i < 5)
                {
                    try
                    {
                         
                        Xml myLabel = new Xml();
                        string completePath = Server.MapPath("~/Promoters/NewEvent/" + u.UserName + "Event" + i + ".xml");

                        if (!System.IO.File.Exists(completePath))
                        {

                            break;

                        }
                        
                        myLabel.TransformSource = "Promoters/NewEvent/XSLTFile1.xslt";
                        
                        System.Xml.XmlTextReader xReader = new System.Xml.XmlTextReader(completePath);

                        while (xReader.Read())
                        {

                            while (xReader.ReadToFollowing("EventClosed"))
                            {
                                string content = xReader.ReadElementContentAsString();
                                if (content == "closed")
                                {
                                    myLabel.TransformSource = "Promoters/NewEvent/XSLTFile3.xslt";
                                }
                            }
                        }
                        xReader.Close();
                        
                        myLabel.DocumentSource = completePath;

                        myLabel.ID = "xml" + i.ToString();

                        PlaceHolder1.Controls.Add(myLabel);
                       

                    }
                    catch
                    {

                    }
                    i++; 
                }
                


            }
        }
#c#net or xml #reading
  • Profile picture of the author sean3838
    I'm an idiot don't listen to me =p I just forgot to change the xslt
    {{ DiscussionBoard.errors[6648573].message }}
  • Profile picture of the author John Ayling
    You're not an idiot - I'm sure that xml/xsl uses a different part of the brain that 'normal' programming does
    Signature
    Software Marketing & Licensing System for WordPress Plugins, Themes & .NET Software
    >> 72 Hour Special <<
    {{ DiscussionBoard.errors[6660731].message }}

Trending Topics