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


C# XPathNavigator.SetValue方法代码示例

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


在下文中一共展示了XPathNavigator.SetValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createSubplatform

        private void createSubplatform(XPathNavigator navLocal, XmlDocument document, XPathNavigator navGlobal)
        {
            //itSubplatforms.Current.CreateAttribute(String.Empty, "name", String.Empty, cName + "Subplatform" + subplatNum++ + AME.Tools.ImportTool.Delimitter + "Subplatform");
            String eventName = navLocal.SelectSingleNode("parent::node()").GetAttribute("name", navLocal.NamespaceURI);

            // Set up component values
            String cType = "Subplatform";
            String cName;
            String cDescription = String.Empty;

            // Create links
            #region links
            
            // SubplatformKind
            String kind = (navLocal.SelectSingleNode("Kind") == null) ? String.Empty : navLocal.SelectSingleNode("Kind").Value;
            kind = kind.Trim();
            if (navGlobal.SelectSingleNode(String.Format("/Scenario/Species[Name='{0}']", kind)) != null)
            {
                // Create component _ Want Kind in the component name.
                cName = navLocal.GetAttribute("name", navLocal.NamespaceURI) + AME.Tools.ImportTool.Delimitter + kind + "_" + cType;
                navLocal.MoveToAttribute("name", navLocal.NamespaceURI);
                navLocal.SetValue(cName);
                navLocal.MoveToParent();
                
                createComponent(VSGConfiguration, document, cType, cName, cDescription);

                createLink(VSGConfiguration, document, cName, cName, kind, "SubplatformKind", String.Empty);
            }
            else
            {
                cName = navLocal.GetAttribute("name", navLocal.NamespaceURI);

                // Create component
                createComponent(VSGConfiguration, document, cType, cName, cDescription);
            }

            // Scenario Link
            createLink(VSGConfiguration, document, navGlobal.SelectSingleNode("/Scenario").GetAttribute("name", navGlobal.NamespaceURI), eventName, cName, "Scenario", String.Empty);


            #endregion

            // Create parameters
            #region parameters

            if (navLocal.SelectSingleNode("Docked") != null)
                createParameter(VSGConfiguration, document, cName, "Component", "Subplatform.DockedCount", (navLocal.SelectSingleNode("Docked/Count") == null) ? String.Empty : navLocal.SelectSingleNode("Docked/Count").Value, String.Empty);

            #endregion

            // Armaments
            Int32 armamentNum = 0;
            XPathNodeIterator itArmaments = navLocal.Select("Armament");
            while (itArmaments.MoveNext())
            {
                itArmaments.Current.CreateAttribute(String.Empty, "name", String.Empty, cName + "Armament" + armamentNum++ + AME.Tools.ImportTool.Delimitter + "Armament");
                createArmament(itArmaments.Current, document, navGlobal);
            }
        }
开发者ID:wshanshan,项目名称:DDD,代码行数:59,代码来源:DDD4_0_2_Importer.cs

示例3: ApplyReplace

		private static void ApplyReplace(XPathNavigator xpNav, XmlReplaceOptions opt,
			Regex rxFind)
		{
			string strData;
			if(opt.Data == XmlReplaceData.InnerText) strData = xpNav.Value;
			else if(opt.Data == XmlReplaceData.InnerXml) strData = xpNav.InnerXml;
			else if(opt.Data == XmlReplaceData.OuterXml) strData = xpNav.OuterXml;
			else return;
			if(strData == null) { Debug.Assert(false); strData = string.Empty; }

			string str = null;
			if(rxFind != null) str = rxFind.Replace(strData, opt.ReplaceText);
			else
			{
				if((opt.Flags & XmlReplaceFlags.CaseSensitive) != XmlReplaceFlags.None)
					str = strData.Replace(opt.FindText, opt.ReplaceText);
				else
					str = StrUtil.ReplaceCaseInsensitive(strData, opt.FindText,
						opt.ReplaceText);
			}

			if((str != null) && (str != strData))
			{
				if(opt.Data == XmlReplaceData.InnerText)
					xpNav.SetValue(str);
				else if(opt.Data == XmlReplaceData.InnerXml)
					xpNav.InnerXml = str;
				else if(opt.Data == XmlReplaceData.OuterXml)
					xpNav.OuterXml = str;
				else { Debug.Assert(false); }
			}
		}
开发者ID:riking,项目名称:go-keepass2,代码行数:32,代码来源:XmlUtil.XmlReplace.cs

示例4: Merge

 private static void Merge(XPathNavigator DstNavi, XmlDocument SrcDoc, string Parent)
 {
     var Current = NodePath(Parent, NodeView(DstNavi));
     if (!string.IsNullOrWhiteSpace(Current))
     {
         if (DstNavi.NodeType == XPathNodeType.Element)
         {
             var SrcElem = SrcDoc.SelectSingleNode(Current);
             if (SrcElem != null)
             {
                 var Frozen = GetFrozenAttributes(Current, FrozenAttributes);
                 if (DstNavi.MoveToFirstAttribute())
                 {
                     do
                     {
                         var SrcElemAttr = SrcElem.Attributes[DstNavi.LocalName];
                         if (SrcElemAttr != null && CanProcess(DstNavi.LocalName, Frozen))
                             DstNavi.SetValue(SrcElemAttr.Value);
                     }
                     while (DstNavi.MoveToNextAttribute());
                     DstNavi.MoveToParent();
                 }
             }
         }
         else if (DstNavi.NodeType == XPathNodeType.Text)
         {
             var SrcElem = SrcDoc.SelectSingleNode(Current);
             if (SrcElem != null)
                 DstNavi.SetValue(SrcElem.InnerText);
         }
         if (DstNavi.MoveToFirstChild())
         {
             do
             {
                 Merge(DstNavi, SrcDoc, Current);
             }
             while (DstNavi.MoveToNext());
             DstNavi.MoveToParent();
         }
         else if (DstNavi.NodeType == XPathNodeType.Element)
         {
             var SrcElem = SrcDoc.SelectSingleNode(Current);
             if (SrcElem != null && !string.IsNullOrWhiteSpace(SrcElem.InnerXml))
                 foreach (XmlNode Child in SrcElem.ChildNodes)
                     DstNavi.AppendChild(Child.CloneNode(true).CreateNavigator());
         }
     }
 }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:48,代码来源:XmlDocumentMerge.cs


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