Beispiel #1
0
 //递归添加content内容
 private void addChild(XmlElement one, XmlDocument doc)
 {
     XmlElement xmle;
     if (one.HasChildNodes)
     {
         xmle = AddContent(one, doc);
         one.PrependChild(xmle);
         for (int i = 1; i < one.ChildNodes.Count; i++)
         {
             addChild((XmlElement)one.ChildNodes[i], doc);
         }
     }
     else
     {
         xmle = AddContent(one, doc);
         one.PrependChild(xmle);
     }
 }
		private static void ProcessIncludeAttribute(XmlElement element, IXmlProcessorEngine engine)
		{
			XmlAttribute include = element.Attributes[IncludeAttrName];

			if (include == null) return;
			// removing the include attribute from the element
			element.Attributes.RemoveNamedItem(IncludeAttrName);

			XmlNode includeContent = includeProcessor.ProcessInclude(element, include.Value, engine);

			if (includeContent != null)
			{
				element.PrependChild(includeContent);
			}
		}
Beispiel #3
0
        //直接和xml打交道的处理和部分对于显示的刷新。
        //把dstXe加到srcXe里
        public static bool insertXmlNode(MainWindow pW, XmlControl xmlCtrl, XmlElement dstXe, XmlElement srcXe, int index = 0)
        {
            XmlElement tmpXe1 = dstXe.OwnerDocument.CreateElement("tmp1");
            XmlElement tmpXe2 = dstXe.OwnerDocument.CreateElement("tmp2");

            if(index < (srcXe.ChildNodes.Count + 1) / 2)
            {
                srcXe.PrependChild(tmpXe1);
                XmlNode iXe = tmpXe1;
                for (int i = 0; i < index; i++)
                {
                    XmlNode nextXe = iXe.NextSibling;

                    srcXe.ReplaceChild(tmpXe2, nextXe);
                    srcXe.ReplaceChild(nextXe, tmpXe1);
                    srcXe.ReplaceChild(tmpXe1, tmpXe2);
                    iXe = tmpXe1;
                }
                srcXe.ReplaceChild(dstXe, tmpXe1);
            }
            else
            {
                srcXe.AppendChild(tmpXe1);
                XmlNode iXe = tmpXe1;
                for (int i = srcXe.ChildNodes.Count - 1; i > index; i--)
                {
                    XmlNode prevXe = iXe.PreviousSibling;

                    srcXe.ReplaceChild(tmpXe2, prevXe);
                    srcXe.ReplaceChild(prevXe, tmpXe1);
                    srcXe.ReplaceChild(tmpXe1, tmpXe2);
                    iXe = tmpXe1;
                }
                srcXe.ReplaceChild(dstXe, tmpXe1);
            }
            if (xmlCtrl != null)
            {
                insertItemByXe(pW, xmlCtrl, dstXe, srcXe, ref index);
            }

            return false;
        }