本文整理汇总了C#中System.Xml.XmlNode.RemoveAll方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.RemoveAll方法的具体用法?C# XmlNode.RemoveAll怎么用?C# XmlNode.RemoveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNode
的用法示例。
在下文中一共展示了XmlNode.RemoveAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: appendElement
public static void appendElement(XmlNode xmlNode, String element, Hashtable properties, Hashtable eventProperties)
{
xmlNode.RemoveAll();
if (properties != null)
{
foreach (string name in properties.Keys)
{
XmlAttribute attr = xmlNode.OwnerDocument.CreateAttribute(name);
attr.InnerText = (string)properties[name];
xmlNode.Attributes.Append(attr);
}
}
if (eventProperties != null)
{
foreach (string name in eventProperties.Keys)
{
XmlNode eventNode = xmlNode.OwnerDocument.CreateNode(XmlNodeType.Element, XMLServicesConstants.XmlNodeEventElt, null);
eventNode.InnerText = (string)eventProperties[name];
xmlNode.AppendChild(eventNode);
XmlAttribute attr = eventNode.OwnerDocument.CreateAttribute(XMLServicesConstants.XmlNodeNameAtt);
attr.InnerText = name;
eventNode.Attributes.Append(attr);
}
}
}
示例2: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
string uNo = Label1.Text;
string oADDRESS = null;
string oEmail = null;
string oName = null;
string Count = null;
int i;
for (i = 1; i < mytable.Rows.Count; i++)
{
if (mytable.Rows[i]["UNO"].ToString().Trim().Equals(uNo))
{
oADDRESS = mytable.Rows[i]["UADDRESS"].ToString();
oEmail = mytable.Rows[i]["UEMAIL"].ToString();
}
}
for (i = 0; i < Table1.Rows.Count-1; i++)
{
oName += Table1.Rows[i].Cells[0].Text+";";
Count += Table1.Rows[i].Cells[1].Text + ";";
}
oName += Table1.Rows[i].Cells[0].Text;
Count += Table1.Rows[i].Cells[1].Text;
db.add_BItem(int.Parse(uNo), oName, oADDRESS, oEmail, "OrderForm", Count);
root = xd.DocumentElement;
root.RemoveAll();
xd.Save(Server.MapPath("gouwuche.xml"));
Response.Write("<script>window.alert('下单成功')</script>");
Response.Redirect("~/index.aspx?id=" + Label1.Text);
}
示例3: Button2_Click
protected void Button2_Click(object sender, EventArgs e)
{
root = xd.DocumentElement;
root.RemoveAll();
xd.Save(Server.MapPath("gouwuche.xml"));
Response.Redirect("~/index.aspx?id=" + Label1.Text);
}
示例4: DeleteNodes
/// <summary>
/// 删除指定节点下的子节点
/// </summary>
/// <param name="XmlFile">Xml文件路径</param>
/// <param name="fatherNode">制定节点</param>
/// <returns>返回真为更新成功,否则失败</returns>
public bool DeleteNodes(string XmlFile, string fatherNode)
{
try
{
xmldoc = new XmlDocument();
xmldoc.Load(XmlFile);
xmlnode = xmldoc.SelectSingleNode(fatherNode);
xmlnode.RemoveAll();
xmldoc.Save(XmlFile);
return true;
}
catch (XmlException xe)
{
throw new XmlException(xe.Message);
}
}
示例5: Apply
public void Apply(XmlNode oldNode, XmlNode newNode)
{
if (newNode == null)
throw new ArgumentNullException(nameof(newNode));
if (oldNode == null)
throw new ArgumentNullException(nameof(oldNode));
Contract.Requires(newNode != null);
Contract.Requires(oldNode != null);
//ToDo: Implement Binding
if(Query.IsBindingQuery(newNode.InnerText))
{
Query.Parse(newNode.InnerText);
// Children Binding - not deep
if(Query.Children)
{
foreach (XmlNode node in oldNode.ChildNodes)
{
var tmpN = newNode.OwnerDocument.ImportNode(node, true);
newNode.RemoveAll();
newNode.AppendChild(tmpN);
}
}
else
{
}
}
foreach (XmlAttribute att in newNode.Attributes)
{
if (Query.IsBindingQuery(att.Value))
{
Query.Parse(att.Value);
newNode.Attributes[Query.Property].Value = oldNode.Attributes[Query.Property]?.Value;
}
}
}
示例6: ProcessRadioGroupLabels
private static void ProcessRadioGroupLabels(XmlNode node)
{
StringCollection optionalValues =
TYml2Xml.GetElements(TXMLParser.GetChild(node, "OptionalValues"));
node.RemoveAll();
XmlNode OptionalValuesLabel = node.OwnerDocument.CreateElement("LabelsForOptionalValues");
node.AppendChild(OptionalValuesLabel);
foreach (string s in optionalValues)
{
string label = s;
if (label.StartsWith("="))
{
label = label.Substring(1).Trim();
}
XmlNode LabelNode = node.OwnerDocument.CreateElement(TYml2Xml.XMLLIST);
OptionalValuesLabel.AppendChild(LabelNode);
TXMLParser.SetAttribute(LabelNode, "name", Catalog.GetString(label));
}
}
示例7: SetPropertiesInstance
/// <summary>
/// Set the custom properties given the properties object
/// </summary>
/// <param name="node"></param>
/// <param name="inst"></param>
public void SetPropertiesInstance(XmlNode node, object inst)
{
node.RemoveAll(); // Get rid of all properties
BarCodeBooklandProperties bcp = inst as BarCodeBooklandProperties;
if (bcp == null)
return;
// ISBN
CreateChild(node, "ISBN", bcp.ISBN);
}
示例8: StripLangTag
private void StripLangTag(XmlNode docNode, XmlNode langNode)
{
List<XmlNode> innerNodeList = new List<XmlNode>();
foreach (XmlNode innerNode in langNode.ChildNodes)
{
innerNodeList.Add(innerNode);
}
langNode.RemoveAll();
foreach (XmlNode innerNode in innerNodeList)
{
docNode.InsertBefore(innerNode, langNode);
}
docNode.RemoveChild(langNode);
}
示例9: ReplaceNode
/// <summary>
/// �ڵ��滻[֧���������ĵ����滻]
/// </summary>
/// <param name="NewXNode"></param>
/// <param name="OldXNode"></param>
public void ReplaceNode(XmlNode newNode, XmlNode oldNode)
{
if (newNode != null && oldNode != null)
{
oldNode.RemoveAll();
//if (!string.IsNullOrEmpty(newNode.InnerXml) && !string.IsNullOrEmpty(newNode.NamespaceURI))
//{
// oldNode.InnerXml = newNode.InnerXml.Replace("xmlns=\"" + newNode.NamespaceURI+"\"", string.Empty);
//}
//else
//{
oldNode.InnerXml = newNode.InnerXml;
//}
XmlAttributeCollection xAttributes = newNode.Attributes;
if (xAttributes != null && xAttributes.Count > 0)
{
for (int i = 0; i < xAttributes.Count; i++)
{
((XmlElement)oldNode).SetAttribute(xAttributes[i].Name, xAttributes[i].Value);
}
}
}
}
示例10: Clear
/// <summary>
/// ����ڵ�,������ڵ�������/����
/// </summary>
/// <param name="OldNode"></param>
public void Clear(XmlNode node)
{
node.RemoveAll();
}
示例11: MoveMasterStyles
/// <summary>
/// Moves the master styles.
/// </summary>
/// <param name="contentDocument">The content document.</param>
/// <param name="nodeAutomaticStyles">The node automatic styles.</param>
/// <param name="nodeMasterPages">The node master pages.</param>
/// <param name="namespaceMng">The namespace MNG.</param>
/// <remarks>
/// We will move the whole master style and master pages stuff
/// from the style document to the text document. This is
/// necessary for avoiding xml document owner errors.
/// Notice: When the document will be saved this nodes have
/// to move back to the styles document. Otherwise they wont
/// work resp. diplayed not correct within OpenOffice.
/// </remarks>
public static void MoveMasterStyles(XmlDocument contentDocument,XmlNode nodeAutomaticStyles, XmlNode nodeMasterPages, XmlNamespaceManager namespaceMng)
{
// First import all automatic styles
XmlNode contentAutomaticStyles = contentDocument.SelectSingleNode(
"//office:automatic-styles", namespaceMng);
if (contentAutomaticStyles != null && nodeAutomaticStyles.HasChildNodes)
{
foreach(XmlNode childNode in nodeAutomaticStyles.ChildNodes)
{
XmlNode importNode = contentDocument.ImportNode(childNode, true);
contentAutomaticStyles.AppendChild(importNode);
}
}
// Second import master pages
XmlNode importedMasterPages = contentDocument.ImportNode(nodeMasterPages, true);
contentDocument.LastChild.AppendChild(importedMasterPages);
// clear nodes in style.xml
nodeAutomaticStyles.RemoveAll();
// clear master pages in style.xml
nodeMasterPages.RemoveAll();
}
示例12: SetPropNodeValue
/// ------------------------------------------------------------------------------------
/// <summary>
/// Sets the value of a node to that found in the specified property. This method
/// specially handles properties that are string collections.
/// </summary>
/// ------------------------------------------------------------------------------------
private void SetPropNodeValue(XmlNode propNode, SettingsPropertyValue propVal)
{
if (propVal.Property.PropertyType != typeof(StringCollection))
{
propNode.InnerText = propVal.SerializedValue.ToString();
return;
}
if (propVal.PropertyValue == null)
return;
// At this point, we know we're dealing with a string collection, therefore,
// create child nodes for each item in the collection.
propNode.RemoveAll();
var attrib = m_settingsXml.CreateAttribute(StrCollectionAttrib);
attrib.Value = "true";
propNode.Attributes.Append(attrib);
int i = 0;
foreach (string str in propVal.PropertyValue as StringCollection)
{
var node = m_settingsXml.CreateElement(propVal.Name + i++);
node.AppendChild(m_settingsXml.CreateTextNode(str));
propNode.AppendChild(node);
}
}
示例13: AdjustLabel
private static void AdjustLabel(XmlNode node, TCodeStorage CodeStorage, XmlDocument AOrigLocalisedYaml)
{
XmlNode TranslatedNode = TXMLParser.FindNodeRecursive(AOrigLocalisedYaml, node.Name);
string TranslatedLabel = string.Empty;
if (TranslatedNode != null)
{
TranslatedLabel = TXMLParser.GetAttribute(TranslatedNode, "Label");
}
TControlDef ctrlDef = new TControlDef(node, CodeStorage);
string Label = ctrlDef.Label;
if ((ctrlDef.GetAttribute("NoLabel") == "true") || (ctrlDef.controlTypePrefix == "pnl")
|| (TXMLParser.FindNodeRecursive(node.OwnerDocument, "act" + ctrlDef.controlName.Substring(ctrlDef.controlTypePrefix.Length)) != null)
|| ctrlDef.GetAttribute("Action").StartsWith("act"))
{
Label = string.Empty;
}
if ((ctrlDef.controlTypePrefix == "rgr") && (TXMLParser.GetChild(node, "OptionalValues") != null))
{
ProcessRadioGroupLabels(node);
}
else if (ctrlDef.controlTypePrefix == "mni")
{
// drop all attributes
node.Attributes.RemoveAll();
foreach (XmlNode menu in node.ChildNodes)
{
if (menu.Name.Contains("Separator"))
{
continue;
}
AdjustLabel(menu, CodeStorage, AOrigLocalisedYaml);
}
}
else
{
// drop all attributes and children nodes
node.RemoveAll();
}
if (Label.Length > 0)
{
if ((TranslatedLabel != Label) && (TranslatedLabel != Catalog.GetString(Label)) && (TranslatedLabel.Length > 0))
{
// add to po file
if (!NewTranslations.ContainsKey(Label))
{
NewTranslations.Add(Label, TranslatedLabel);
}
TXMLParser.SetAttribute(node, "Label", TranslatedLabel);
}
else
{
TXMLParser.SetAttribute(node, "Label", Catalog.GetString(Label));
}
}
}
示例14: CreateStundenProfil
private void CreateStundenProfil (XmlNode StundenProfilContainer, SortedList StundenProfil)
{
StundenProfilContainer.RemoveAll ();
String OldMaschine = "";
XmlNode MaschineNode = null;
foreach (DictionaryEntry ProfilEntry in StundenProfil)
{
String [] EntryContent = ((String)ProfilEntry.Key).Split (' ');
if (OldMaschine != EntryContent [0])
{
OldMaschine = EntryContent [0];
MaschineNode = InsertContainerNode (StundenProfilContainer, OldMaschine);
}
InsertTextNode (MaschineNode, "H_" + EntryContent [1], (String) ProfilEntry.Value);
}
}
示例15: SetPropertiesInstance
/// <summary>
/// Set the custom properties given the properties object
/// </summary>
/// <param name="node"></param>
/// <param name="inst"></param>
public void SetPropertiesInstance(XmlNode node, object inst)
{
node.RemoveAll(); // Get rid of all properties
BarCodeProperties bcp = inst as BarCodeProperties;
if (bcp == null)
return;
// NumberSystem
CreateChild(node, "NumberSystem", bcp.NumberSystem);
// ManufacturerCode
CreateChild(node, "ManufacturerCode", bcp.ManufacturerCode);
// ProductCode
CreateChild(node, "ProductCode", bcp.ProductCode);
}