當前位置: 首頁>>代碼示例>>C#>>正文


C# XPathNavigator.CreateAttribute方法代碼示例

本文整理匯總了C#中System.Xml.XPath.XPathNavigator.CreateAttribute方法的典型用法代碼示例。如果您正苦於以下問題:C# XPathNavigator.CreateAttribute方法的具體用法?C# XPathNavigator.CreateAttribute怎麽用?C# XPathNavigator.CreateAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.XPath.XPathNavigator的用法示例。


在下文中一共展示了XPathNavigator.CreateAttribute方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SetOrCreateXmlAttribute

 public static void SetOrCreateXmlAttribute(XPathNavigator node, string localName, string namespaceURI, string value)
 {
     if (node.MoveToAttribute(localName, namespaceURI))
     {
         node.SetValue(value);
         node.MoveToParent();
     }
     else
     {
         node.CreateAttribute("", localName, namespaceURI, value);
     }
 }
開發者ID:neemask,項目名稱:meta-core,代碼行數:12,代碼來源:CyphyMetaLinkUtils.cs

示例2: SetXmlType

		public void SetXmlType(string name, string namespaceUri, XPathNavigator source)
		{
			namespaceUri = GetEffectiveNamespace(namespaceUri);
			var prefix = CreateNamespace(null, namespaceUri, source);
			source.CreateAttribute("xsi", "type", Xsi, GetQualifiedName(prefix, name));
		}
開發者ID:n2cms,項目名稱:Castle.Core,代碼行數:6,代碼來源:XPathContext.cs

示例3: CreateAttribute

		public XPathNavigator CreateAttribute(string name, string namespaceUri, XPathNavigator source)
		{
			source.CreateAttribute(null, name, namespaceUri, "");
			source.MoveToAttribute(name, namespaceUri ?? "");
			return source;
		}
開發者ID:n2cms,項目名稱:Castle.Core,代碼行數:6,代碼來源:XPathContext.cs

示例4: CreateNamespace

		public string CreateNamespace(string prefix, string namespaceUri, XPathNavigator source)
		{
			if (string.IsNullOrEmpty(namespaceUri) == false)
			{
				source = source.Clone();
				source.MoveToRoot();
				source.MoveToChild(XPathNodeType.Element);

				if (string.IsNullOrEmpty(prefix))
					prefix = AddNamespace(namespaceUri);

				var existing = source.GetNamespace(prefix);
				if (existing == namespaceUri) return prefix;
				if (string.IsNullOrEmpty(existing) == false) return null;

				source.CreateAttribute("xmlns", prefix, "", namespaceUri);
			}
			return prefix;
		}
開發者ID:n2cms,項目名稱:Castle.Core,代碼行數:19,代碼來源:XPathContext.cs

示例5: NormalizeNamespaces

        private static void NormalizeNamespaces(XPathNavigator src, XPathNavigator dest) {
            IDictionary<string, string> dictLocal = src.GetNamespacesInScope(XmlNamespaceScope.ExcludeXml);
            IDictionary<string, string> dictExclude = dest.GetNamespacesInScope(XmlNamespaceScope.Local);

            foreach(KeyValuePair<string, string> pair in dictLocal)
                if(!dictExclude.ContainsKey(pair.Key))
                    dest.CreateAttribute("xmlns", pair.Key, "http://www.w3.org/2000/xmlns/", pair.Value);
        }
開發者ID:NelsonSantos,項目名稱:fyiReporting-Android,代碼行數:8,代碼來源:MakeXmlSignature.cs

示例6: MakeNil

		public bool MakeNil(XPathNavigator source)
		{
			if (source.NodeType == XPathNodeType.Element && IsNil(source) == false)
			{
				source.CreateAttribute("xsi", "nil", Xsi, "true");
				return true;
			}
			return false;
		}
開發者ID:Orvid,項目名稱:NAntUniversalTasks,代碼行數:9,代碼來源:XPathContext.cs

示例7: CreateAttribute

		public XPathNavigator CreateAttribute(string name, string namespaceUri, XPathNavigator source)
		{
			name = XmlConvert.EncodeLocalName(name);
			source.CreateAttribute(null, name, namespaceUri, "");
			source.MoveToAttribute(name, namespaceUri ?? "");
			return source;
		}
開發者ID:Orvid,項目名稱:NAntUniversalTasks,代碼行數:7,代碼來源:XPathContext.cs

示例8: MakeNil

		public bool MakeNil(XPathNavigator source)
		{
			if (source.NodeType == XPathNodeType.Element && IsNil(source) == false)
			{
				if (source.LookupPrefix(Xsi) != "xsi")
					CreateNamespace("xsi", Xsi, source);
				source.CreateAttribute("xsi", "nil", Xsi, "true");
				return true;
			}
			return false;
		}
開發者ID:Jarvin-Guan,項目名稱:CleanAOP,代碼行數:11,代碼來源:XPathContext.cs

示例9: CreateAttribute

		public XPathNavigator CreateAttribute(string name, string namespaceUri, XPathNavigator source)
		{
			string prefix;
			name = XmlConvert.EncodeLocalName(name);
			if (IsRootNamespace(namespaceUri, out prefix))
				prefix = CreateNamespace(prefix, namespaceUri, source);
			source.CreateAttribute(prefix, name, namespaceUri, "");
			source.MoveToAttribute(name, namespaceUri ?? "");
			return source;
		}
開發者ID:Jarvin-Guan,項目名稱:CleanAOP,代碼行數:10,代碼來源:XPathContext.cs

示例10: SetXmlStringAttributeValue

        public static bool SetXmlStringAttributeValue(XPathNavigator parentNode, string valueName, string newValue)
        {
            if (parentNode == null || string.IsNullOrEmpty(valueName))
            {
                return false;
            }
            try
            {
                XPathNavigator factory = parentNode.Clone();
                do
                {
                    factory.MoveToFirstAttribute();

                    if (string.Compare(factory.Name, valueName) == 0)
                    {
                        factory.SetValue(newValue);
                        return true;
                    }
                }
                while (!factory.MoveToNextAttribute());

                parentNode.CreateAttribute(string.Empty,
                                           valueName,
                                           string.Empty,
                                           newValue);
                return true;
            }
            catch (ArgumentNullException)
            {
            }
            catch (InvalidOperationException)
            {
            }
            return false;
        }
開發者ID:2594636985,項目名稱:SharpDevelop,代碼行數:35,代碼來源:XmlHelperClass.cs


注:本文中的System.Xml.XPath.XPathNavigator.CreateAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。