internal protected override void Associate(XmlDocument /*!*/ document) { if (!IsAssociated) { XmlCDataSection = document.CreateCDataSection(dataImpl); } }
/// <summary> /// Appends a CData section to a XML node and prefills the provided data. /// </summary> /// <param name="cData">The CData section value.</param> /// <param name="sourceNode">The parent node.</param> public static void AppendCDataSectionTo(this string cData, XmlNode sourceNode) { XmlDocument document = sourceNode is XmlDocument ? (XmlDocument)sourceNode : sourceNode.OwnerDocument; XmlCDataSection node = document.CreateCDataSection(cData); sourceNode.AppendChild(node); }
public static void SetPropertyCData(string property, Control field) { var propertyNode = _rootNode.SelectSingleNode("air:" + property.Replace("/", "/air:"), _namespaceManager); if (propertyNode != null) { if (field.Text != "") { XmlCDataSection x = _descriptorFile.CreateCDataSection(field.Text); propertyNode.RemoveAll(); propertyNode.AppendChild(x); } else { // Remove the node, reverting to system default GetParentNode(property).RemoveChild(propertyNode); } } else { // Only add property if there is a value to add if (field.Text != "") { var index = property.IndexOf('/'); var childName = property.Substring(index + 1, property.Length - (index + 1)); propertyNode = _descriptorFile.CreateNode(XmlNodeType.Element, childName, _namespaceManager.LookupNamespace("air")); if (propertyNode != null) { XmlCDataSection x = _descriptorFile.CreateCDataSection(field.Text); propertyNode.AppendChild(x); GetParentNode(property).AppendChild(propertyNode); } } } }
string GetValueFromElement(XmlElement ele, string name, BindType type) { switch (type) { case BindType.Default: { return(ele.GetAttribute(name)); } case BindType.CDATA: { XmlElement eleValue = (XmlElement)ele.SelectSingleNode(string.Format("cdata[@type='{0}']", name)); if (eleValue == null) { return(""); } else { XmlCDataSection cdata = (XmlCDataSection)eleValue.FirstChild; if (cdata == null) { return(""); } else { return(cdata.Value); } } } default: throw new ArgumentException("未知的type:" + type, "type"); } }
protected void savetopic_Click(object sender, EventArgs e) { #region 保存主题修改 XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNodeList topiclistNode = doc.SelectNodes("/Aggregationinfo/Aggregationpage/Website/Forum/Topiclist/Topic"); XmlNodeInnerTextVisitor topicvisitor = new XmlNodeInnerTextVisitor(); foreach (XmlNode topic in topiclistNode) { topicvisitor.SetNode(topic); if (topicvisitor["topicid"] == topicid.Value) { topicvisitor["topicid"] = topicid.Value; topicvisitor["title"] = tbtitle.Text; topicvisitor["poster"] = poster.Text; topicvisitor["postdatetime"] = postdatetime.Text; XmlCDataSection shortDes = doc.CreateCDataSection("shortdescription"); shortDes.InnerText = shortdescription.Text; topicvisitor.GetNode("shortdescription").RemoveAll(); topicvisitor.GetNode("shortdescription").AppendChild(shortDes); break; } } doc.Save(configPath); Response.Redirect("aggregation_editforumaggset.aspx"); #endregion }
/// <summary> /// CultureInfo.Name /// </summary> /// <param name="cultureCode">CultureInfo.Name</param> /// <returns></returns> public string this[string cultureName] { get { XmlNodeList list = doc.GetElementsByTagName(cultureName); if (list.Count == 0) { return(null); } string tmp = list[0].InnerText; tmp = normalizeLineEndings(tmp); return(tmp); } set { bool changed = false; XmlNodeList list = doc.GetElementsByTagName(cultureName); if (list.Count == 1) { doc.DocumentElement.RemoveChild(list[0]); changed = true; } if (!string.IsNullOrEmpty(value)) { XmlElement element = doc.CreateElement(cultureName); XmlCDataSection xmlCData = doc.CreateCDataSection(value); element.AppendChild(xmlCData); doc.DocumentElement.AppendChild(element); changed = true; } if (changed) { onContentChanged(); } } }
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node) { string content = prop.CastValue <Content>(); string type = "null"; if (prop.HasRawBuffer) { type = "binary"; } else if (content.Length > 0) { type = "url"; } XmlElement contentType = doc.CreateElement(type); if (type == "binary") { XmlCDataSection cdata = doc.CreateCDataSection(content); contentType.AppendChild(cdata); } else { contentType.InnerText = content; } node.AppendChild(contentType); }
private void SaveFavorites() { try { XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><favorites/>"); foreach (TreeNode node in tv.Nodes) { if (node.Text != "" && node.Tag != null && node.Tag is string && (string)node.Tag != "") { XmlNode favorite = xmldoc.CreateElement("favorite"); XmlNode title = xmldoc.CreateElement("title"); title.InnerText = node.Text; favorite.AppendChild(title); XmlCDataSection cdata = xmldoc.CreateCDataSection((string)node.Tag); XmlNode url = xmldoc.CreateElement("url"); url.AppendChild(cdata); favorite.AppendChild(url); xmldoc.DocumentElement.AppendChild(favorite); } } xmldoc.Save(PropertyService.ConfigDirectory + help2FavoritesFile); } catch {} }
/// <summary> /// 在指定的Xml元素下,添加子Xml元素,同时带属性 /// </summary> /// <param name="xmlElement"></param> /// <param name="xValue"></param> /// <param name="attrName"></param> /// <param name="attrValue"></param> /// <param name="IsCDataSection"></param> /// <returns></returns> public bool AddChildWhitAttributes(ref XmlElement xmlElement, string xValue, string attrName, string attrValue, bool IsCDataSection) { if ((xmlElement != null) && (xmlElement.OwnerDocument != null)) { if (IsCDataSection) { XmlCDataSection tempdata = xmlElement.OwnerDocument.CreateCDataSection(attrName); tempdata.InnerText = xValue; xmlElement.AppendChild(tempdata); XmlAttribute xa = xmlElement.OwnerDocument.CreateAttribute(attrName); xa.Value = attrValue; xmlElement.Attributes.Append(xa); } else { XmlAttribute xa = xmlElement.OwnerDocument.CreateAttribute(attrName); xa.Value = attrValue; xmlElement.Attributes.Append(xa); xmlElement.InnerText = xValue; } return(true); } else { return(false); } }
static public void SetValue(XmlElement parentEle, string itemNodeName, ItemsDataMode dataMode, string value) { XmlElement node = (XmlElement)parentEle.SelectSingleNode(itemNodeName); if (node == null) { node = parentEle.OwnerDocument.CreateElement(itemNodeName); parentEle.AppendChild(node); } switch (dataMode) { case ItemsDataMode.ValueProperty: node.SetAttribute("value", value); break; case ItemsDataMode.Text: node.InnerText = value; break; case ItemsDataMode.CData: RemoveAllChilds(node); XmlCDataSection cdata = parentEle.OwnerDocument.CreateCDataSection(value); node.AppendChild(cdata); break; default: throw new Exception("开发期错误。未知的ItemsDataMode:" + dataMode); } }
//------------------------------------------------------------------------------ /// <summary> /// Writes given message to the trace file /// </summary> /// <param name="msg"></param> public void writeln(string msg) { if (theSwitch.Level == TraceLevel.Off) { return; } try { this.open(); XmlDocument xml_doc = new XmlDocument(); xml_doc.Load(this.file_path); XmlElement ele_line = xml_doc.CreateElement("line"); XmlAttribute att_time = xml_doc.CreateAttribute("timestamp"); att_time.Value = timestamp(); ele_line.SetAttributeNode(att_time); // do this so that CDATA section may be created from embded CDATA section if (msg.IndexOf("CDATA") < 0) { XmlCDataSection cd_section = xml_doc.CreateCDataSection(msg); ele_line.AppendChild(cd_section); } else { XmlComment cm_section = xml_doc.CreateComment(msg); ele_line.AppendChild(cm_section); } xml_doc.DocumentElement.AppendChild(ele_line); xml_doc.Save(this.file_path); xml_doc = null; } catch (Exception x) { evlog.internal_log.error(x); x = null; } }
// Check the properties on a newly constructed CDATA section. private void CheckProperties(String msg, XmlCDataSection cdata, String value, bool failXml) { String temp; AssertEquals(msg + " [1]", "#cdata-section", cdata.LocalName); AssertEquals(msg + " [2]", "#cdata-section", cdata.Name); AssertEquals(msg + " [3]", String.Empty, cdata.Prefix); AssertEquals(msg + " [4]", String.Empty, cdata.NamespaceURI); AssertEquals(msg + " [5]", XmlNodeType.CDATA, cdata.NodeType); AssertEquals(msg + " [6]", value, cdata.Data); AssertEquals(msg + " [7]", value, cdata.Value); AssertEquals(msg + " [8]", value, cdata.InnerText); AssertEquals(msg + " [9]", value.Length, cdata.Length); AssertEquals(msg + " [10]", String.Empty, cdata.InnerXml); if(failXml) { try { temp = cdata.OuterXml; Fail(msg + " [11]"); } catch(ArgumentException) { // Success } } else { AssertEquals(msg + " [12]", "<![CDATA[" + value + "]]>", cdata.OuterXml); } }
public GsmXmlReader insertParameter2(GsmXmlParameter parameter) { if (parameter.prev_xml_node != null) { XmlElement xmlElement = xmlDoc.CreateElement(parameter.parameter_type); xmlElement.SetAttribute("Name", parameter.parameter_name); xmlElement.InnerXml = parameter.inner_xml; var ParameterList = xmlElement.ChildNodes; //XmlCDataSection CData = xmlDoc.CreateCDataSection(text); //Script3dNode.InnerText = ""; //Script3dNode.AppendChild(CData); foreach (XmlNode paramDescrElement in ParameterList) { if (paramDescrElement != null && paramDescrElement.Name == "Description") { XmlCDataSection CData = xmlDoc.CreateCDataSection("\"" + parameter.parameter_label + "\""); paramDescrElement.InnerText = ""; paramDescrElement.AppendChild(CData); } if (paramDescrElement != null && paramDescrElement.Name == "Value") { paramDescrElement.InnerText = parameter.parameter_value; } } XmlNode Parameters = xmlDoc.SelectSingleNode("/Symbol/ParamSection/Parameters"); if (!added_parameters.ContainsKey(parameter.parameter_name)) { Parameters.InsertAfter(xmlElement, parameter.prev_xml_node); added_parameters[parameter.parameter_name] = 1; MessageBox.Show("Added " + parameter.parameter_name); } } return(this); }
/// <summary> /// Set field value, if not exits will add new one. /// </summary> /// <param name="key"></param> /// <param name="value"></param> /// <returns></returns> /// <exception cref="ArgumentOutOfRangeException"></exception> public void Set(String key, String value) { XmlNode node = this._rootNode.SelectSingleNode(String.Format("add[@key='{0}']", key)); if (node == null) { this.Add(key, value ?? "", false); return; //throw new ArgumentOutOfRangeException("key", "no such key named \"" + key + "\""); } //如果不是文本注释,删除第一个节点并重新保存值 if (node.FirstChild != null) { if (node.FirstChild.Name == "#cdata-section") { XmlCDataSection xmlCDataSection = node.FirstChild as XmlCDataSection; if (xmlCDataSection != null) { xmlCDataSection.InnerText = value ?? ""; } } else { node.RemoveChild(node.FirstChild); node.InsertBefore(_xdoc.CreateCDataSection(value ?? ""), node.FirstChild); } } else { node.AppendChild(_xdoc.CreateCDataSection(value ?? "")); } }
private XmlElement BuildIntegrationElement(XmlDocument ownerDocument, IIntegrationResult result) { XmlElement integrationElement = CreateElement(ownerDocument, "item"); integrationElement.AppendChild(CreateTextElement(integrationElement.OwnerDocument, "title", "Build {0} : {1} {2} {3}", result.Label, result.Status, GetAmountOfModifiedFiles(result), GetFirstCommentedModification(result))); integrationElement.AppendChild(CreateTextElement( integrationElement.OwnerDocument, "description", GetAmountOfModifiedFiles(result))); integrationElement.AppendChild(CreateTextElement( integrationElement.OwnerDocument, "guid", System.Guid.NewGuid().ToString())); integrationElement.AppendChild(CreateTextElement( integrationElement.OwnerDocument, "pubDate", System.DateTime.Now.ToString("r", CultureInfo.CurrentCulture))); if (result.HasModifications()) { XmlElement modsElement = CreateContentElement( integrationElement.OwnerDocument, "encoded"); XmlCDataSection cdata = integrationElement.OwnerDocument.CreateCDataSection( GetBuildModifications(result)); modsElement.AppendChild(cdata); integrationElement.AppendChild(modsElement); } return(integrationElement); }
private static XmlCDataSection CreateCDataSection(XmlElement parent, string data) { XmlCDataSection section = parent.OwnerDocument.CreateCDataSection(data); parent.AppendChild(section); return(section); }
/// <summary> /// 在指定的Xml元素下,添加子Xml元素 /// </summary> /// <param name="xmlElement">被追加子元素的Xml元素</param> /// <param name="childElementName">要添加的Xml元素名称</param> /// <param name="childElementValue">要添加的Xml元素值</param> /// <param name="IsCDataSection">是否是CDataSection类型的子元素</param> /// <returns></returns> public bool AppendChildElementByNameValue(ref XmlElement xmlElement, string childElementName, object childElementValue, bool IsCDataSection) { if ((xmlElement != null) && (xmlElement.OwnerDocument != null)) { //是否是CData类型Xml元素 if (IsCDataSection) { XmlCDataSection tempdata = xmlElement.OwnerDocument.CreateCDataSection(childElementName); tempdata.InnerText = FiltrateControlCharacter(childElementValue.ToString()); XmlElement childXmlElement = xmlElement.OwnerDocument.CreateElement(childElementName); childXmlElement.AppendChild(tempdata); xmlElement.AppendChild(childXmlElement); } else { XmlElement childXmlElement = xmlElement.OwnerDocument.CreateElement(childElementName); childXmlElement.InnerText = FiltrateControlCharacter(childElementValue.ToString()); xmlElement.AppendChild(childXmlElement); } return(true); } else { return(false); } }
public SqlXml(string file) { this._InnerDocument.Load(file); this.SqlDictionary = new Dictionary <string, string>(); foreach (XmlNode node in this._InnerDocument.DocumentElement.ChildNodes) { if (node.NodeType != XmlNodeType.Element && node.LocalName != "sql") { continue; } XmlElement ele = (XmlElement)node; foreach (XmlNode subnode in ele.ChildNodes) { if (subnode.NodeType != XmlNodeType.CDATA) { continue; } XmlCDataSection cdata = (XmlCDataSection)subnode; this.SqlDictionary.Add(ele.GetAttribute("name"), cdata.InnerText); } } this.Host = this._InnerDocument.DocumentElement.GetAttribute("host"); this.Dbname = this._InnerDocument.DocumentElement.GetAttribute("dbname"); this.UserName = this._InnerDocument.DocumentElement.GetAttribute("username"); this.PassWord = this._InnerDocument.DocumentElement.GetAttribute("password"); }
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node) { if (!prop.HasRawBuffer) { return; } byte[] data = prop.RawBuffer; string value = Convert.ToBase64String(data); if (value.Length > 72) { string buffer = ""; while (value.Length > 72) { string chunk = value.Substring(0, 72); value = value.Substring(72); buffer += chunk + '\n'; } value = buffer + value; } XmlCDataSection cdata = doc.CreateCDataSection(value); node.AppendChild(cdata); }
void ValidateNode(XmlNode node) { XmlElement e = node as XmlElement; if (e != null) { ValidateElement(e); return; } XmlText t = node as XmlText; if (t != null) { ValidateText(t); return; } XmlCDataSection cd = node as XmlCDataSection; if (cd != null) { ValidateText(cd); return; } XmlWhitespace w = node as XmlWhitespace; if (w != null) { ValidateWhitespace(w); return; } }
private static string GetSoapXml(string url, string methodName, Dictionary <string, string> @params) { string xmlns = GetXmlns(url); bool isQualified = GetElementFormDefault(url) == "qualified"; XmlDocument doc = new XmlDocument(); doc.AppendChild(doc.CreateXmlDeclaration("1.0", Encoding.UTF8.BodyName, null)); XmlElement soapEnvelope = doc.CreateElement("soap", "Envelope", "http://schemas.xmlsoap.org/soap/envelope/"); soapEnvelope.SetAttribute("xmlns:z", xmlns); XmlElement soapBody = doc.CreateElement("soap", "Body", "http://schemas.xmlsoap.org/soap/envelope/"); XmlElement methodNameDocumnet = doc.CreateElement("z", methodName, xmlns); foreach (var param in @params) { XmlElement content = isQualified ? doc.CreateElement("z", param.Key, xmlns) : doc.CreateElement(param.Key); XmlCDataSection cData = doc.CreateCDataSection(param.Value); content.AppendChild(cData); methodNameDocumnet.AppendChild(content); } soapBody.AppendChild(methodNameDocumnet); soapEnvelope.AppendChild(soapBody); doc.AppendChild(soapEnvelope); return(doc.InnerXml); }
internal void UpdateProjectPreference(XmlElement pref) { if (MainForm.CurrentProject == null) { lockObject = new object(); } else { lockObject = MainForm.CurrentProject; } lock (lockObject) { string psName = PROJECT_PS_PREFIX + Name; XmlHelper req = new XmlHelper("<Request/>"); req.AddElement(".", "Space"); req.AddElement("Space", "Name", psName); XmlElement content = req.AddElement("Space", "Content"); XmlCDataSection section = content.OwnerDocument.CreateCDataSection(pref.OuterXml); content.AppendChild(section); MainForm.LoginArgs.GreeningConnection.SendRequest("UpdateSpace", new Envelope(req)); this.Preference = pref; } }
public void GetIssueParameter(XmlNode parameterNode, int parameterNum, string parameterValue) { string str = parameterNode.Attributes["type"].Value; XmlDocument ownerDocument = (this.DataContext as XmlElement).OwnerDocument; if (str == "combo") { XmlNode xmlNode = parameterNode.SelectSingleNode("selected"); if (xmlNode == null) { XmlElement element = ownerDocument.CreateElement("selected"); parameterNode.AppendChild((XmlNode)element); xmlNode = (XmlNode)element; } int num = 0; foreach (XmlNode selectNode in parameterNode.SelectNodes("value")) { if (selectNode.Attributes["name"].Value.ToString() == parameterValue) { xmlNode.InnerText = num.ToString(); } ++num; } } else { parameterNode.InnerXml = string.Empty; XmlElement element = ownerDocument.CreateElement("value"); XmlCDataSection cdataSection = ownerDocument.CreateCDataSection(""); cdataSection.InnerText = parameterValue; element.AppendChild((XmlNode)cdataSection); parameterNode.AppendChild((XmlNode)element); } }
// Check the properties on a newly constructed CDATA section. private void CheckProperties(String msg, XmlCDataSection cdata, String value, bool failXml) { String temp; AssertEquals(msg + " [1]", "#cdata-section", cdata.LocalName); AssertEquals(msg + " [2]", "#cdata-section", cdata.Name); AssertEquals(msg + " [3]", String.Empty, cdata.Prefix); AssertEquals(msg + " [4]", String.Empty, cdata.NamespaceURI); AssertEquals(msg + " [5]", XmlNodeType.CDATA, cdata.NodeType); AssertEquals(msg + " [6]", value, cdata.Data); AssertEquals(msg + " [7]", value, cdata.Value); AssertEquals(msg + " [8]", value, cdata.InnerText); AssertEquals(msg + " [9]", value.Length, cdata.Length); AssertEquals(msg + " [10]", String.Empty, cdata.InnerXml); if (failXml) { try { temp = cdata.OuterXml; Fail(msg + " [11]"); } catch (ArgumentException) { // Success } } else { AssertEquals(msg + " [12]", "<![CDATA[" + value + "]]>", cdata.OuterXml); } }
public void formatToXML() { XmlDocument xmlLibr = new XmlDocument(); XmlDeclaration xmlDecl = xmlLibr.CreateXmlDeclaration("1.0", "utf-8", null); xmlLibr.AppendChild(xmlDecl); XmlElement xmlLibrary = xmlLibr.CreateElement("library"); foreach (Book bk in _library) { XmlElement bookElement = xmlLibr.CreateElement("book"); XmlElement authorElemnet = xmlLibr.CreateElement("author"); authorElemnet.InnerText = bk.author; XmlElement yearElement = xmlLibr.CreateElement("year"); yearElement.InnerText = bk.year; XmlElement titleElement = xmlLibr.CreateElement("name"); titleElement.SetAttribute("language", "en"); XmlCDataSection titleSection = xmlLibr.CreateCDataSection(bk.name); titleElement.AppendChild(titleSection); bookElement.AppendChild(authorElemnet); bookElement.AppendChild(yearElement); bookElement.AppendChild(titleElement); xmlLibrary.AppendChild(bookElement); } xmlLibr.AppendChild(xmlLibrary); xmlLibr.Save("library.xml"); }
private void button1_Click(object sender, EventArgs e) { XmlElement employee = doc.CreateElement("employee"); XmlElement firstname = doc.CreateElement("firstname"); XmlElement lastname = doc.CreateElement("lastname"); XmlElement homephone = doc.CreateElement("homephone"); XmlElement notes = doc.CreateElement("notes"); XmlAttribute employeeid = doc.CreateAttribute("employeeid"); employeeid.Value = comboBox1.Text; XmlText firstnametext = doc.CreateTextNode(textBox1.Text); XmlText lastnametext = doc.CreateTextNode(textBox2.Text); XmlText homephonetext = doc.CreateTextNode(textBox3.Text); XmlCDataSection notestext = doc.CreateCDataSection(textBox4.Text); employee.Attributes.Append(employeeid); employee.AppendChild(firstname); employee.AppendChild(lastname); employee.AppendChild(homephone); employee.AppendChild(notes); firstname.AppendChild(firstnametext); lastname.AppendChild(lastnametext); homephone.AppendChild(homephonetext); notes.AppendChild(notestext); doc.DocumentElement.AppendChild(employee); doc.Save(Application.StartupPath + "/employees.xml"); UpdateLabel(); }
public override void WriteCData(string text) { XmlCDataSection cdata = current.OwnerDocument.CreateCDataSection(text); current.AppendChild(cdata); document.AppendChild(current, cdata); }
private string ReadChildNodeValue(XmlNode item, string childNodeName) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (string.IsNullOrWhiteSpace(childNodeName)) { throw new ArgumentNullException(nameof(childNodeName)); } XmlNode childNode = item.SelectSingleNode(childNodeName); if (childNode == null) { return(null); } if (childNode.HasChildNodes) { XmlCDataSection xmlCDataSection = childNode.FirstChild as XmlCDataSection; if (xmlCDataSection != null) { return(xmlCDataSection.Data); } XmlText xmlText = childNode.FirstChild as XmlText; if (xmlText != null) { return(xmlText.Value); } } return(childNode.InnerText); }
/// <summary> /// Tip: can be used in child classes /// </summary> /// <param name="xmlDocument"></param> /// <returns></returns> public override XmlElement SerializeToXml(XmlDocument xmlDocument) { XmlElement taskElement = xmlDocument.CreateElement(string.Empty, "Element", string.Empty); //xmlDocument.AppendChild(taskElement); taskElement.SetAttribute("Name", Name); taskElement.SetAttribute("Description", Description); taskElement.SetAttribute("Metadata-type", GetType().Name); XmlElement taskTextElement = xmlDocument.CreateElement(string.Empty, "TaskText", string.Empty); taskElement.AppendChild(taskTextElement); taskTextElement.InnerText = TaskText; // Image to Xml if (Picture != null) { MemoryStream ms = new MemoryStream(); Picture.Save(ms, Picture.RawFormat); byte[] rawData = ms.ToArray(); XmlCDataSection cdata = xmlDocument.CreateCDataSection(Encoding.ASCII.GetString(rawData)); taskElement.AppendChild(cdata); } return(taskElement); }
/// <summary> /// Create an element for a document. /// </summary> /// <param name="doc">The document to create the element for.</param> /// <param name="name">The name of the element.</param> /// <returns>The new element.</returns> public static XmlCDataSection AddCDataSection(XmlDocument doc, XmlElement ele, object data) { XmlCDataSection cdata = CreateCDataSection(doc, data); ele.AppendChild(cdata); return(cdata); }
/// <summary> /// 创建处理器 /// </summary> /// <param name="requestXml">请求的xml</param> /// <returns>IHandler对象</returns> public static IHandler CreateHandler(string requestXml) { IHandler handler = null; if (!string.IsNullOrEmpty(requestXml)) { //解析数据 XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(requestXml); XmlNode node = doc.SelectSingleNode("/xml/MsgType"); if (node != null) { XmlCDataSection section = node.FirstChild as XmlCDataSection; if (section != null) { string msgType = section.Value; switch (msgType) { case "text": handler = new TextHandler(requestXml); break; case "event": handler = new EventHandler(requestXml); break; } } } } return(handler); }
public override XmlNode CloneNode (bool deep) { XmlNode n = new XmlCDataSection (Data, OwnerDocument); // CDATA nodes have no children. return n; }