本文整理汇总了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);
}
}
示例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);
}
}
示例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); }
}
}
示例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());
}
}
}