示例#1
0
        private static void GenerateHeadings(XmlNodeList headings, Heading parent, ref int index)
        {
            while (index < headings.Count)
            {
                int headingLevel = GetHeadingLevel(headings[index].Name);

                if (headingLevel == 0)
                {
                    // not an heading -> skip
                    index++;
                }
                else if (headingLevel <= parent.Level)
                {
                    return;
                }
                else if (headingLevel > parent.Level)
                {
                    // generate the header only for heading with ID attribute
                    string  id      = CheckForId(parent, (XmlElement)headings[index]);
                    Heading subHead = new Heading(headings[index].InnerText, id, headingLevel);
                    parent.AddChild(subHead);

                    index++;                            // read next

                    GenerateHeadings(headings, subHead, ref index);
                }
                else
                {
                    throw new ArgumentOutOfRangeException("index");
                }
            }
        }
示例#2
0
        private static void GenerateHeadings(System.Xml.XmlNodeList headings, Heading parent, ref int index)
        {
            while (index < headings.Count)
              {
            int headingLevel = GetHeadingLevel(headings[index].Name);

            if (headingLevel == 0)
            {
              //not an heading
              index++; // Skip
            }
            else if (headingLevel <= parent.Level)
            {
              return;
            }
            else if (headingLevel > parent.Level)
            {
              //Generate the header only for heading with ID attribute
              string id = CheckForId(parent, (System.Xml.XmlElement)headings[index]);
              Heading subHead = new Heading(headings[index].InnerText, id, headingLevel);
              parent.AddChild(subHead);

              index++; // Read next

              GenerateHeadings(headings, subHead, ref index);
            }
            else
              throw new ArgumentOutOfRangeException("index");
              }
        }