Пример #1
0
 /// <summary>
 /// Print this Document to a FILE stream.
 /// </summary>
 public override void Print(StringBuilder cfile, int depth)
 {
     //assert( cfile );
     for (TiXmlNode node = FirstChild(); node != null; node = node.NextSibling())
     {
         node.Print(cfile, depth);
         //fprintf(cfile, "\n");
         cfile.Append("\n");
     }
 }
Пример #2
0
 /// <summary>
 /// This flavor of IterateChildren searches for children with a particular 'value'
 /// </summary>
 public TiXmlNode IterateChildren(string _value, TiXmlNode previous)
 {
     if (previous == null)
     {
         return(FirstChild(_value));
     }
     else
     {
         //assert( previous.parent == this );
         return(previous.NextSibling(_value));
     }
 }
Пример #3
0
 /// <summary>
 /// Walk the XML tree visiting this node and all of its children.
 /// </summary>
 public override bool Accept(TiXmlVisitor visitor)
 {
     if (visitor.VisitEnter(this))
     {
         for (TiXmlNode node = FirstChild(); node != null; node = node.NextSibling())
         {
             if (!node.Accept(visitor))
             {
                 break;
             }
         }
     }
     return(visitor.VisitExit(this));
 }
Пример #4
0
 /// <summary>
 /// Return a handle to the "index" child. The first child is 0, the second 1, etc.
 /// </summary>
 TiXmlHandle Child(int count)
 {
     if (node != null)
     {
         int       i;
         TiXmlNode child = node.FirstChild();
         for (i = 0; child != null && i < count; child = child.NextSibling(), ++i)
         {
             // nothing
         }
         if (child != null)
         {
             return(new TiXmlHandle(child));
         }
     }
     return(new TiXmlHandle());
 }
Пример #5
0
        private void CopyTo(TiXmlDocument target)
        {
            base.CopyTo(target);

            target.error           = error;
            target.errorId         = errorId;
            target.errorDesc       = errorDesc;
            target.tabsize         = tabsize;
            target.errorLocation   = errorLocation.Clone();
            target.useMicrosoftBOM = useMicrosoftBOM;

            TiXmlNode node = null;

            for (node = firstChild; node != null; node = node.NextSibling())
            {
                target.LinkEndChild(node.Clone());
            }
        }
Пример #6
0
        protected void CopyTo(TiXmlElement target)
        {
            // superclass:
            base.CopyTo(target);

            // Element class:
            // Clone the attributes, then clone the children.
            TiXmlAttribute attribute = null;

            for (attribute = attributeSet.First(); attribute != null; attribute = attribute.Next())
            {
                target.SetAttribute(attribute.Name(), attribute.Value());
            }

            TiXmlNode node = null;

            for (node = firstChild; node != null; node = node.NextSibling())
            {
                target.LinkEndChild(node.Clone());
            }
        }
Пример #7
0
        /// <summary>
        /// Print the Element to a FILE stream.
        /// </summary>
        public override void Print(StringBuilder cfile, int depth)
        {
            //assert( cfile );
            for (int i = 0; i < depth; i++)
            {
                //fprintf( cfile, "    " );
                cfile.Append("    ");
            }

            cfile.Append("<"); cfile.Append(value);
            //fprintf( cfile, "<%s", value.c_str() );

            for (TiXmlAttribute attrib = attributeSet.First(); attrib != null; attrib = attrib.Next())
            {
                cfile.Append(" ");
                //fprintf(cfile, " ");
                attrib.Print(cfile, depth);
            }

            // There are 3 different formatting approaches:
            // 1) An element without children is printed as a <foo /> node
            // 2) An element with only a text child is printed as <foo> text </foo>
            // 3) An element with children is printed on multiple lines.
            if (firstChild == null)
            {
                //fprintf(cfile, " />");
                cfile.Append(" />");
            }
            else if (firstChild == lastChild && firstChild.ToText() != null)
            {
                //fprintf(cfile, ">");
                cfile.Append(">");
                firstChild.Print(cfile, depth + 1);
                //fprintf(cfile, "</%s>", value.c_str());
                cfile.Append("</"); cfile.Append(value); cfile.Append(">");
            }
            else
            {
                //fprintf(cfile, ">");
                cfile.Append(">");

                for (TiXmlNode node = firstChild; node != null; node = node.NextSibling())
                {
                    if (node.ToText() == null)
                    {
                        //fprintf(cfile, "\n");
                        cfile.Append("\n");
                    }
                    node.Print(cfile, depth + 1);
                }
                //fprintf(cfile, "\n");
                cfile.Append("\n");
                for (int i = 0; i < depth; ++i)
                {
                    //fprintf(cfile, "    ");
                    cfile.Append("    ");
                }
                //fprintf(cfile, "</%s>", value.c_str());
                cfile.Append("</"); cfile.Append(value); cfile.Append(">");
            }
        }