public void ValidateXmlFormat() { if (XMLDoc == null) { XMLData = "<genxml></genxml>"; // if we don;t have anything, create an empty default to stop errors. } if (XMLDoc.SelectSingleNode("genxml/hidden") == null) { SetXmlProperty("genxml/hidden", ""); } if (XMLDoc.SelectSingleNode("genxml/textbox") == null) { SetXmlProperty("genxml/textbox", ""); } if (XMLDoc.SelectSingleNode("genxml/checkbox") == null) { SetXmlProperty("genxml/checkbox", ""); } if (XMLDoc.SelectSingleNode("genxml/dropdownlist") == null) { SetXmlProperty("genxml/dropdownlist", ""); } if (XMLDoc.SelectSingleNode("genxml/radiobuttonlist") == null) { SetXmlProperty("genxml/radiobuttonlist", ""); } if (XMLDoc.SelectSingleNode("genxml/checkboxlist") == null) { SetXmlProperty("genxml/checkboxlist", ""); } }
/// <summary> /// Replace xml node in NBrightInfo structure /// </summary> /// <param name="strXml">New XML, must be in NBright Strucutre (genxml/...)</param> /// <param name="xPathSource">Source path of the xml, this is for the new node and the old existing node</param> /// <param name="xPathRootDestination">parent node to place the new node onto</param> /// <param name="addNode">add if the node doesn;t already exists.</param> public void ReplaceXmlNode(string strXml, string xPathSource, string xPathRootDestination, bool addNode = true) { var xmlDocNew = new XmlDocument(); xmlDocNew.LoadXml(strXml); var xmlNod = XMLDoc.SelectSingleNode(xPathSource); if (xmlNod != null) { var xmlNod2 = xmlDocNew.SelectSingleNode(xPathSource); if (xmlNod2 != null) { var newNod = XMLDoc.ImportNode(xmlNod2, true); var selectSingleNode = XMLDoc.SelectSingleNode(xPathRootDestination); if (selectSingleNode != null) { selectSingleNode.ReplaceChild(newNod, xmlNod); XMLData = XMLDoc.OuterXml; } } } else { if (addNode) { AddXmlNode(strXml, xPathSource, xPathRootDestination); } } }
public void ValidateXmlFormat() { if (XMLDoc == null) { XMLData = GenXmlFunctions.GetGenXml(new RepeaterItem(0, ListItemType.Item)); // if we don;t have anything, create an empty default to stop errors. } if (XMLDoc.SelectSingleNode("genxml/hidden") == null) { SetXmlProperty("genxml/hidden", ""); } if (XMLDoc.SelectSingleNode("genxml/textbox") == null) { SetXmlProperty("genxml/textbox", ""); } if (XMLDoc.SelectSingleNode("genxml/checkbox") == null) { SetXmlProperty("genxml/checkbox", ""); } if (XMLDoc.SelectSingleNode("genxml/dropdownlist") == null) { SetXmlProperty("genxml/dropdownlist", ""); } if (XMLDoc.SelectSingleNode("genxml/radiobuttonlist") == null) { SetXmlProperty("genxml/radiobuttonlist", ""); } }
public void RemoveXref(string nodeName, string value) { //Removexref node, if there. if (XMLDoc.SelectSingleNode("genxml/" + nodeName + "/id[.='" + value + "']") != null) { RemoveXmlNode("genxml/" + nodeName + "/id[.='" + value + "']"); } }
public void RemoveXmlNode(string xPath) { var xmlNod = XMLDoc.SelectSingleNode(xPath); if (xmlNod != null) { if (xmlNod.ParentNode != null) { xmlNod.ParentNode.RemoveChild(xmlNod); } } XMLData = XMLDoc.OuterXml; }
public void AddXref(string nodeName, string value) { //create node if not there. if (XMLDoc.SelectSingleNode("genxml/" + nodeName) == null) { AddXmlNode("<genxml><" + nodeName + "></" + nodeName + "></genxml>", "genxml/" + nodeName, "genxml"); } //Add new xref node, if not there. if (XMLDoc.SelectSingleNode("genxml/" + nodeName + "/id[.='" + value + "']") == null) { AddXmlNode("<genxml><" + nodeName + "><id>" + value + "</id></" + nodeName + "></genxml>", "genxml/" + nodeName + "/id", "genxml/" + nodeName); } }
/// <summary> /// Add a XML node to a parent destination /// </summary> /// <param name="strXml">source XML</param> /// <param name="xPathSource">source xpath</param> /// <param name="xPathRootDestination">parent xpath in destination</param> public void AddXmlNode(string strXml, string xPathSource, string xPathRootDestination) { var xmlDocNew = new XmlDocument(); xmlDocNew.LoadXml(strXml); var xmlTarget = XMLDoc.SelectSingleNode(xPathRootDestination); if (xmlTarget != null) { var xmlNod2 = xmlDocNew.SelectSingleNode(xPathSource); if (xmlNod2 != null) { var newNod = XMLDoc.ImportNode(xmlNod2, true); xmlTarget.AppendChild(newNod); XMLData = XMLDoc.OuterXml; } } }
public string GetXmlNode(string xpath) { if (!string.IsNullOrEmpty(_xmlData) & XMLDoc != null) { try { var selectSingleNode = XMLDoc.SelectSingleNode(xpath); if (selectSingleNode != null) { return(selectSingleNode.InnerXml); } } catch (Exception ex) { return("XML READ ERROR"); } } return(""); }