This code was written by me,in a late night moment,when copy paste seems the best option
It started this way :
public string ImportFeed(string URL)
        {
            string ret = "";
            XmlDocument xd = new XmlDocument();
            xd.Load(URL);            
            for(int i=0;i<xd.ChildNodes.Count;i++)
            {
                ret += xd.ChildNodes[i].Name;
            }
            return ret;
            
        }
So far,nothing special. Just open the url,read into an XML,return first nodes. Then I wanted more – next nodes. Nothing easier – why bother with recursion or proper variable names ? Just copy and paste :
public string ImportFeed(string URL)
        {
            string ret = "";
            XmlDocument xd = new XmlDocument();
            xd.Load(URL);            
            for(int i=0;i<xd.ChildNodes.Count;i++)
            {
                ret += xd.ChildNodes[i].Name;
                for (int j = 0; i < xd.ChildNodes[i].ChildNodes.Count; j++)
                {
                    ret += xd.ChildNodes[i].ChildNodes[j].Name;
                }
            }
            return ret;
            
        }
Could you spot the error ?
Hint : I have discovered after 10 seconds …but not looking at the code…
Leave a Reply to Matthias Krells Cancel reply