当前位置: 首页>>代码示例>>C#>>正文


C# XmlElement.SetAttributeNode方法代码示例

本文整理汇总了C#中System.Xml.XmlElement.SetAttributeNode方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElement.SetAttributeNode方法的具体用法?C# XmlElement.SetAttributeNode怎么用?C# XmlElement.SetAttributeNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlElement的用法示例。


在下文中一共展示了XmlElement.SetAttributeNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: saveToFile

 protected virtual XmlElement saveToFile(XmlDocument doc, XmlElement root)
 {
     XmlAttribute name = doc.CreateAttribute(PetriXmlHelper.XML_BASEITEM_NAMESPACE_PREFIX, "name", PetriXmlHelper.XML_BASEITEM_NAMESPACE);
     name.Value = this.name;
     root.SetAttributeNode(name);
     XmlAttribute unid = doc.CreateAttribute(PetriXmlHelper.XML_BASEITEM_NAMESPACE_PREFIX, "unid", PetriXmlHelper.XML_BASEITEM_NAMESPACE);
     unid.Value = this.unid.ToString();
     root.SetAttributeNode(unid);
     XmlAttribute showAnnotation = doc.CreateAttribute(PetriXmlHelper.XML_BASEITEM_NAMESPACE_PREFIX, "showannotation", PetriXmlHelper.XML_BASEITEM_NAMESPACE);
     showAnnotation.Value = this.showAnnotation.ToString();
     root.SetAttributeNode(showAnnotation);
     return root;
 }
开发者ID:davidbedok,项目名称:UBPNS,代码行数:13,代码来源:AbstractItem.xml.cs

示例2: writeItemData

 protected XmlElement writeItemData(XmlDocument doc, XmlElement root)
 {
     XmlAttribute name = doc.CreateAttribute(PetriXmlHelper.XML_BASEITEM_NAMESPACE_PREFIX, AbstractItem.XML_NAME, PetriXmlHelper.XML_BASEITEM_NAMESPACE);
     name.Value = this.name;
     root.SetAttributeNode(name);
     XmlAttribute unid = doc.CreateAttribute(PetriXmlHelper.XML_BASEITEM_NAMESPACE_PREFIX, AbstractItem.XML_UNID, PetriXmlHelper.XML_BASEITEM_NAMESPACE);
     unid.Value = this.unid.ToString();
     root.SetAttributeNode(unid);
     XmlAttribute showAnnotation = doc.CreateAttribute(PetriXmlHelper.XML_BASEITEM_NAMESPACE_PREFIX, AbstractItem.XML_SHOWANNOTATION, PetriXmlHelper.XML_BASEITEM_NAMESPACE);
     showAnnotation.Value = this.showAnnotation.ToString();
     root.SetAttributeNode(showAnnotation);
     return root;
 }
开发者ID:davidbedok,项目名称:UBPNS,代码行数:13,代码来源:AbstractItem.save.xml.cs

示例3: CreateAndAppendAttribute

 public static XmlAttribute CreateAndAppendAttribute(XmlElement parent, string name, string value)
 {
     XmlAttribute xAttribute = parent.OwnerDocument.CreateAttribute(name);
     if (value != String.Empty)
         xAttribute.Value = value;
     parent.SetAttributeNode(xAttribute);
     return xAttribute;
 }
开发者ID:Stoner19,项目名称:Memory-Lifter,代码行数:8,代码来源:XmlHelper.cs

示例4: saveToFile

 protected override XmlElement saveToFile(XmlDocument doc, XmlElement root)
 {
     base.saveToFile(doc, root);
     XmlAttribute attachedItem = doc.CreateAttribute(PetriXmlHelper.XML_NOTE_NAMESPACE_PREFIX, "attachedItem", PetriXmlHelper.XML_NOTE_NAMESPACE);
     attachedItem.Value = this.attachedItem.Unid.ToString();
     root.SetAttributeNode(attachedItem);
     XmlElement text = doc.CreateElement(PetriXmlHelper.XML_NOTE_NAMESPACE_PREFIX, "Text", PetriXmlHelper.XML_NOTE_NAMESPACE);
     text.InnerText = this.text;
     root.AppendChild(text);
     return root;
 }
开发者ID:davidbedok,项目名称:UBPNS,代码行数:11,代码来源:AbstractNote.xml.cs

示例5: Init

 public void Init()
 {
     base.Init();
     elementCreator=new GraphConnectorElementCreator(xmiDocument,documentBuilder);
     parentElement=GraphNodeElementStub.CreateGraphNodeElementStub(xmiDocument);
     graphEdgeElement=GraphEdgeElementStub.CreateGraphEdgeElementStub(xmiDocument);
     XmlAttribute idAttr=xmiDocument.CreateAttribute("xmi","id",XmiElements.XMI_NAMESPACE_URI);
     idAttr.Value=GRAPH_EDGE_ELEMENT_ID;
     graphEdgeElement.SetAttributeNode(idAttr);
     //graphEdgeElement.SetAttribute(XmiElements.XMI_ID_ATTR_NAME,XmiElements.XMI_NAMESPACE_URI,GRAPH_EDGE_ELEMENT_ID);
 }
开发者ID:xueliu,项目名称:MSC_Generator,代码行数:11,代码来源:GraphConnectorElementCreatorTest.cs

示例6: AddAttributeNode

        public XmlAttribute AddAttributeNode(XmlElement node, string name, string value)
        {
            XmlAttribute a = xmlDoc.CreateAttribute(name);
            a.Value = value;

            if (node == null)
                xmlDoc.DocumentElement.SetAttributeNode(a);
            else
              node.SetAttributeNode(a);

             return a;
        }
开发者ID:BackupTheBerlios,项目名称:sofia-svn,代码行数:12,代码来源:XmlDocumentFacade.cs

示例7: saveToFile

 protected override XmlElement saveToFile(XmlDocument doc, XmlElement root)
 {
     base.saveToFile(doc, root);
     root.AppendChild(PetriXmlHelper.savePointF(doc, this.point, "TopLeftPoint"));
     root.AppendChild(PetriXmlHelper.savePointF(doc, this.origo, "Origo"));
     root.AppendChild(PetriXmlHelper.savePointF(doc, this.labelOffset, "LabelOffset"));
     root.AppendChild(PetriXmlHelper.saveSizeF(doc, this.size, "Size"));
     XmlAttribute radius = doc.CreateAttribute(PetriXmlHelper.XML_ITEM_NAMESPACE_PREFIX, "radius", PetriXmlHelper.XML_ITEM_NAMESPACE);
     radius.Value = this.radius.ToString();
     root.SetAttributeNode(radius);
     return root;
 }
开发者ID:davidbedok,项目名称:UBPNS,代码行数:12,代码来源:AbstractNetworkItem.xml.cs

示例8: saveToFile

 protected override XmlElement saveToFile(XmlDocument doc, XmlElement root)
 {
     base.saveToFile(doc, root);
     root.AppendChild(PetriXmlHelper.savePointF(doc, this.clockOffset, "ClockOffset"));
     XmlAttribute angle = doc.CreateAttribute(PetriXmlHelper.XML_TRANSITION_NAMESPACE_PREFIX, "angle", PetriXmlHelper.XML_TRANSITION_NAMESPACE);
     angle.Value = this.angle.ToString();
     root.SetAttributeNode(angle);
     XmlAttribute priority = doc.CreateAttribute(PetriXmlHelper.XML_TRANSITION_NAMESPACE_PREFIX, "priority", PetriXmlHelper.XML_TRANSITION_NAMESPACE);
     priority.Value = this.priority.ToString();
     root.SetAttributeNode(priority);
     XmlAttribute transitionType = doc.CreateAttribute(PetriXmlHelper.XML_TRANSITION_NAMESPACE_PREFIX, "type", PetriXmlHelper.XML_TRANSITION_NAMESPACE);
     transitionType.Value = this.transitionType.Value;
     root.SetAttributeNode(transitionType);
     XmlAttribute delay = doc.CreateAttribute(PetriXmlHelper.XML_TRANSITION_NAMESPACE_PREFIX, "delay", PetriXmlHelper.XML_TRANSITION_NAMESPACE);
     delay.Value = this.delay.ToString();
     root.SetAttributeNode(delay);
     XmlAttribute clockRadius = doc.CreateAttribute(PetriXmlHelper.XML_TRANSITION_NAMESPACE_PREFIX, "clockRadius", PetriXmlHelper.XML_TRANSITION_NAMESPACE);
     clockRadius.Value = this.clockRadius.ToString();
     root.SetAttributeNode(clockRadius);
     return root;
 }
开发者ID:davidbedok,项目名称:UBPNS,代码行数:21,代码来源:AbstractTransition.xml.cs

示例9: AddNamespaces

 internal static void AddNamespaces(XmlElement elem, Hashtable namespaces)
 {
     if (namespaces != null)
     {
         foreach (string str in namespaces.Keys)
         {
             if (!elem.HasAttribute(str))
             {
                 XmlAttribute newAttr = elem.OwnerDocument.CreateAttribute(str);
                 newAttr.Value = namespaces[str] as string;
                 elem.SetAttributeNode(newAttr);
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:Utils.cs

示例10: FixupNamespaceNodes

		private void FixupNamespaceNodes (XmlElement src, XmlElement dst, bool ignoreDefault)
		{
			// add namespace nodes
			foreach (XmlAttribute attr in src.SelectNodes ("namespace::*")) {
				if (attr.LocalName == "xml")
					continue;
				if (ignoreDefault && attr.LocalName == "xmlns")
					continue;
				dst.SetAttributeNode (dst.OwnerDocument.ImportNode (attr, true) as XmlAttribute);
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:SignedXml.cs

示例11: RecCompXML

        /// <summary>
        /// Used by CompressXML
        /// </summary>
        /// <param name="counts">Map of attribute to number of occurrences -- could be used to improve algorithm</param>
        /// <param name="entities">Map of attribute to entity name</param>
        /// <param name="doc"></param>
        /// <param name="el"></param>
        /// <param name="idx">Number that is incremented to provide new entity names</param>
        private static void RecCompXML(Hashtable counts, Hashtable entities, XmlDocument doc, XmlElement el, ref int idx)
        {
            ArrayList keys = new ArrayList();

            foreach(XmlAttribute att in el.Attributes)
            {
                //don't try to do anything with xmlns nodes.
                if (att.Name.IndexOf("xmlns") == -1)
                    keys.Add(att.Name);
            }

            foreach(string s in keys)
            {
                string val = el.Attributes[s].Value;

                if (counts[val] == null)
                {
                    counts[val] = 1;
                }
                else
                {
                    counts[val] = (int)counts[val] + 1;
                }

                if (val.Length > 30)
                {
                    string entname;

                    if(entities[val] == null)
                    {
                        idx += 1;
                        entname = "E"+idx.ToString();
                        entities[val] = entname;
                    }
                    else
                    {
                        entname = (string)entities[val];
                    }

                    XmlAttribute attr;

                    //xlinks are a special case at the moment as the .NET XML API requires whatever bit of code
                    //outputs a qualified name to *just magically happen to know* the URI that the prefix refers to.
                    if (s.IndexOf("xlink") == 0)
                    {
                        attr = doc.CreateAttribute(s, "http://www.w3.org/1999/xlink");
                    }
                    else
                    {
                        attr = doc.CreateAttribute(s);
                    }

                    attr.AppendChild(doc.CreateEntityReference(entname));
                    el.SetAttributeNode(attr);
                }

            }

            foreach(XmlNode ch in el.ChildNodes)
            {
                if (ch.GetType() == typeof(XmlElement))
                    RecCompXML(counts, entities, doc, (XmlElement)ch, ref idx);
            }
        }
开发者ID:djpnewton,项目名称:ddraw,代码行数:72,代码来源:SvgElementFactory.cs

示例12: RecCompXML

        /// <summary>
        /// Used by CompressXML
        /// </summary>
        /// <param name="counts">Map of attribute to number of occurrences -- could be used to improve algorithm</param>
        /// <param name="entities">Map of attribute to entity name</param>
        /// <param name="doc"></param>
        /// <param name="el"></param>
        /// <param name="idx">Number that is incremented to provide new entity names</param>
        private static void RecCompXML(Hashtable counts, Hashtable entities, XmlDocument doc, XmlElement el, ref int idx)
        {
            ArrayList keys = new ArrayList();

            foreach(XmlAttribute att in el.Attributes)
            {
                keys.Add(att.Name);
            }

            foreach(string s in keys)
            {
                string val = el.Attributes[s].Value;

                if (counts[val] == null)
                {
                    counts[val] = 1;
                }
                else
                {
                    counts[val] = (int)counts[val] + 1;
                }

                if (val.Length > 30)
                {
                    string entname;

                    if(entities[val] == null)
                    {
                        idx += 1;
                        entname = "E"+idx.ToString();
                        entities[val] = entname;
                    }
                    else
                    {
                        entname = (string)entities[val];
                    }

                    XmlAttribute attr = doc.CreateAttribute(s);
                    attr.AppendChild(doc.CreateEntityReference(entname));
                    el.SetAttributeNode(attr);
                }

            }

            foreach(XmlNode ch in el.ChildNodes)
            {
                if (ch.GetType() == typeof(XmlElement))
                    RecCompXML(counts, entities, doc, (XmlElement)ch, ref idx);
            }
        }
开发者ID:ryosuzuki,项目名称:drh-horology,代码行数:58,代码来源:SvgElementFactory.cs

示例13: AddNamespaces

 internal static void AddNamespaces (XmlElement elem, CanonicalXmlNodeList namespaces) {
     if (namespaces != null) {
         foreach (XmlNode attrib in namespaces) {
             string name = ((attrib.Prefix.Length > 0) ? attrib.Prefix + ":" + attrib.LocalName : attrib.LocalName);
             // Skip the attribute if one with the same qualified name already exists
             if (elem.HasAttribute(name) || (name.Equals("xmlns") && elem.Prefix.Length == 0)) continue;
             XmlAttribute nsattrib = (XmlAttribute) elem.OwnerDocument.CreateAttribute(name);
             nsattrib.Value = attrib.Value;
             elem.SetAttributeNode(nsattrib);
         }
     }
 }
开发者ID:mind0n,项目名称:hive,代码行数:12,代码来源:utils.cs

示例14: SetAttribute

 private void SetAttribute(XmlElement element, string nsuri, string prefix, string localname, string val)
 {
     XmlAttribute attr = doc.CreateAttribute(prefix, localname, nsuri);
     attr.Value = val;
     element.SetAttributeNode(attr);
 }
开发者ID:JoshData,项目名称:semweb-dotnet,代码行数:6,代码来源:RdfXmlWriter.cs

示例15: FillNodeChildrenFromRow

		private void FillNodeChildrenFromRow (DataRow row, XmlElement element)
		{
			DataTable table = row.Table;
			// fill columns for the row
			for (int i = 0; i < table.Columns.Count; i++) {
				DataColumn col = table.Columns [i];
				string value = row.IsNull (col) ? String.Empty : row [col].ToString ();
				switch (col.ColumnMapping) {
				case MappingType.Element:
					XmlElement el = CreateElement (col.Prefix, XmlHelper.Encode (col.ColumnName), col.Namespace);
					el.InnerText = value;
					element.AppendChild (el);
					break;
				case MappingType.Attribute:
					XmlAttribute attr = CreateAttribute (col.Prefix, XmlHelper.Encode (col.ColumnName), col.Namespace);
					attr.Value = value;
					element.SetAttributeNode (attr);
					break;
				case MappingType.SimpleContent:
					XmlText text = CreateTextNode (value);
					element.AppendChild (text);
					break;
				// FIXME: how to handle hidden?
				}
			}
		}
开发者ID:t-ashula,项目名称:mono,代码行数:26,代码来源:XmlDataDocument.cs


注:本文中的System.Xml.XmlElement.SetAttributeNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。