/// <summary> /// 由于ChannelElement根据属性type要生成不同的类型,所以不能用AnyXmlElement里的逻辑. /// </summary> public override XmlNode Clone() { ChannelSimpleExXmlElement channelEle = Activator.CreateInstance(this.GetType(), this.OwnerDocument) as ChannelSimpleExXmlElement; XmlUtilService.CopyXmlElement(this, channelEle); return(channelEle); }
public override XmlNode Clone() { AnyXmlElement targetEle = OwnerDocument.CreateElement(this.Name) as AnyXmlElement; XmlUtilService.CopyXmlElement(this, targetEle); return(targetEle); }
/// <summary> /// 通过XmlElement的OuterXml返回的字符串生成XmlElement /// </summary> public XmlElement ParseElement(string outerXml) { XmlDocument doc = new XmlDocument(); doc.LoadXml(outerXml); XmlElement newEle = this.CreateElement(doc.DocumentElement.Name); XmlUtilService.CopyXmlElement(doc.DocumentElement, newEle); return(newEle); }
/// <summary> /// 获得所有的snip节点拷贝 /// </summary> public Dictionary <string, XmlElement> GetAllSnipElementClone() { Dictionary <string, XmlElement> _cloneDic = new Dictionary <string, XmlElement>(); XmlNodeList snipNodes = this.DocumentElement.SelectNodes(@"//snip[@hasSnip='True']"); foreach (XmlNode node in snipNodes) { XmlElement ele = (XmlElement)node; XmlElement cloneEle = ele.OwnerDocument.CreateElement(ele.Name); XmlUtilService.CopyXmlElement(ele, cloneEle); string id = ele.GetAttribute("id"); Debug.Assert(!string.IsNullOrEmpty(id)); _cloneDic.Add(id, cloneEle); } return(_cloneDic); }