本文整理汇总了C#中System.Xml.XPath.XPathNavigator.MoveToFirstAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XPathNavigator.MoveToFirstAttribute方法的具体用法?C# XPathNavigator.MoveToFirstAttribute怎么用?C# XPathNavigator.MoveToFirstAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XPath.XPathNavigator
的用法示例。
在下文中一共展示了XPathNavigator.MoveToFirstAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadXml
public void ReadXml(XPathNavigator node)
{
if (node.MoveToFirstAttribute()) {
do {
if (String.IsNullOrEmpty(node.NamespaceURI)) {
switch (node.LocalName) {
case "address":
this.Address = node.Value;
break;
case "display-name":
this.DisplayName = node.Value;
break;
default:
break;
}
}
} while (node.MoveToNextAttribute());
node.MoveToParent();
}
}
示例2: Parse
private void Parse(XPathNavigator classCacheElement)
{
if (classCacheElement.MoveToFirstAttribute())
{
do
{
switch (classCacheElement.Name)
{
case "class":
if (classCacheElement.Value.Trim().Length == 0)
throw new HibernateConfigException("Invalid class-cache element; the attribute <class> must be assigned with no empty value");
clazz = classCacheElement.Value;
break;
case "usage":
usage = EntityCacheUsageParser.Parse(classCacheElement.Value);
break;
case "region":
region = classCacheElement.Value;
break;
case "include":
include = CfgXmlHelper.ClassCacheIncludeConvertFrom(classCacheElement.Value);
break;
}
}
while (classCacheElement.MoveToNextAttribute());
}
}
示例3: XmlNodeTaskItem
/// <summary>
/// Initializes a new instance of an XmlNodeTaskItem
/// </summary>
/// <param name="xpathNavigator">The selected XmlNode</param>
/// <param name="reservedMetaDataPrefix">The prefix to attach to the reserved metadata properties.</param>
public XmlNodeTaskItem(XPathNavigator xpathNavigator, string reservedMetaDataPrefix)
{
this.ReservedMetaDataPrefix = reservedMetaDataPrefix;
switch (xpathNavigator.NodeType)
{
case XPathNodeType.Attribute:
itemSpec = xpathNavigator.Value;
break;
default:
itemSpec = xpathNavigator.Name;
break;
}
metaData.Add(ReservedMetaDataPrefix + "value", xpathNavigator.Value);
metaData.Add(ReservedMetaDataPrefix + "innerXml", xpathNavigator.InnerXml);
metaData.Add(ReservedMetaDataPrefix + "outerXml", xpathNavigator.OuterXml);
if (xpathNavigator.MoveToFirstAttribute())
{
do
{
metaData.Add(xpathNavigator.Name, xpathNavigator.Value);
} while (xpathNavigator.MoveToNextAttribute());
}
}
示例4: ParameterNode
public ParameterNode(XPathNavigator aNode)
{
valueNode = String.Empty;
typeNode = String.Empty;
ruleValueNode = String.Empty;
name = String.Empty;
if (aNode.MoveToFirstAttribute())
{
do
{
string nodeName = aNode.Name;
switch (nodeName)
{
case PARAMETER_ATTRS.NAME:
name = aNode.Value;
break;
case PARAMETER_ATTRS.VALUE:
valueNode = aNode.Value;
break;
case PARAMETER_ATTRS.TYPE:
typeNode = aNode.Value;
break;
case PARAMETER_ATTRS.RULE_VALUE:
ruleValueNode = aNode.Value;
break;
}
} while (aNode.MoveToNextAttribute());
aNode.MoveToParent();
}
}
示例5: MSXslScript
public MSXslScript (XPathNavigator nav, Evidence evidence)
{
this.evidence = evidence;
code = nav.Value;
if (nav.MoveToFirstAttribute ()) {
do {
switch (nav.LocalName) {
case "language":
switch (nav.Value.ToLower (CultureInfo.InvariantCulture)) {
case "jscript":
case "javascript":
language = ScriptingLanguage.JScript; break;
case "vb":
case "visualbasic":
language = ScriptingLanguage.VisualBasic;
break;
case "c#":
case "csharp":
language = ScriptingLanguage.CSharp;
break;
default:
throw new XsltException ("Invalid scripting language!", null);
}
break;
case "implements-prefix":
implementsPrefix = nav.Value;
break;
}
} while (nav.MoveToNextAttribute ());
nav.MoveToParent ();
}
if (implementsPrefix == null)
throw new XsltException ("need implements-prefix attr", null);
}
示例6: ReadXml
public void ReadXml(XPathNavigator node, XmlResolver resolver)
{
if (node.NodeType == XPathNodeType.Element) {
if (node.MoveToFirstAttribute()) {
do {
switch (node.LocalName) {
case "media-type":
this.MediaType = node.Value;
break;
case "boundary":
this.Boundary = node.Value;
break;
}
} while (node.MoveToNextAttribute());
node.MoveToParent();
}
if (node.MoveToChild(XPathNodeType.Element)) {
XPathHttpMultipartItem currentItem = null;
do {
if (node.NamespaceURI == XPathHttpClient.Namespace) {
switch (node.LocalName) {
case "header":
if (currentItem == null) {
currentItem = new XPathHttpMultipartItem();
}
currentItem.Headers.Add(node.GetAttribute("name", ""), node.GetAttribute("value", ""));
break;
case "body":
if (currentItem == null) {
currentItem = new XPathHttpMultipartItem();
}
currentItem.Body = new XPathHttpBody();
currentItem.Body.ReadXml(node, resolver);
this.Items.Add(currentItem);
currentItem = null;
break;
}
}
} while (node.MoveToNext(XPathNodeType.Element));
node.MoveToParent();
}
}
}
示例7: Parse
private void Parse(XPathNavigator eventElement)
{
XPathNavigator eventClone = eventElement.Clone();
eventElement.MoveToFirstAttribute();
type = CfgXmlHelper.ListenerTypeConvertFrom(eventElement.Value);
XPathNodeIterator listenersI = eventClone.SelectDescendants(XPathNodeType.Element, false);
while (listenersI.MoveNext())
{
listeners.Add(new ListenerConfiguration(listenersI.Current, type));
}
}
示例8: GetAssemblyVersion
string GetAssemblyVersion(XPathNavigator nav)
{
if(nav.HasAttributes)
nav.MoveToFirstAttribute();
do
{
if (Utilities.Compare(nav.LocalName, "version"))
return nav.Value;
} while (nav.MoveToNextAttribute( ));
return string.Empty;
}
示例9: SettingsMappingWhatContents
public SettingsMappingWhatContents (XPathNavigator nav, SettingsMappingWhatOperation operation)
{
_operation = operation;
if (nav.HasAttributes) {
nav.MoveToFirstAttribute ();
_attributes.Add (nav.Name, nav.Value);
while (nav.MoveToNextAttribute ())
_attributes.Add (nav.Name, nav.Value);
}
}
示例10: GetAttributes
public static Dictionary<string, string> GetAttributes(XPathNavigator navigator)
{
if (!navigator.MoveToFirstAttribute())
throw new DeserializationException("Node has no attributes: " + navigator.Name);
Dictionary<string, string> attributes = new Dictionary<string, string>();
do
{
attributes.Add(navigator.Name, navigator.Value);
} while (navigator.MoveToNextAttribute());
navigator.MoveToParent();
return attributes;
}
示例11: ReadXml
public void ReadXml(XPathNavigator node) {
if (node.MoveToFirstAttribute()) {
do {
if (String.IsNullOrEmpty(node.NamespaceURI)) {
switch (node.LocalName) {
case "method":
switch (node.Value) {
case "xml":
this.Method = XmlSerializationOptions.Methods.Xml;
break;
case "html":
this.Method = XmlSerializationOptions.Methods.Html;
break;
case "xhtml":
this.Method = XmlSerializationOptions.Methods.XHtml;
break;
case "text":
this.Method = XmlSerializationOptions.Methods.Text;
break;
}
break;
default:
break;
}
}
} while (node.MoveToNextAttribute());
node.MoveToParent();
}
if (node.MoveToFirstChild()) {
do {
if (node.NodeType == XPathNodeType.Element || node.NodeType == XPathNodeType.Text) {
this.Content = node.Clone();
break;
}
} while (node.MoveToNext());
node.MoveToParent();
}
}
示例12: WriteAttributes
private static void WriteAttributes(TextWriter writer, XPathNavigator nav, string leadIn)
{
nav.MoveToFirstAttribute();
do
{
writer.Write(leadIn);
writer.Write(nav.Name);
writer.Write(Constants.Space);
writer.WriteLine(nav.Value);
} while (nav.MoveToNextAttribute());
nav.MoveToParent();
}
示例13: ParseAppTag
/// <summary>
/// Parses the "version" node represented by a <see cref="XPathNavigator"/> object.
/// </summary>
/// <param name="xpathNav">The <see cref="XPathNavigator"/> object containing the "version" node.</param>
/// <returns>An instance of the <see cref="AppVersionInfo"/> class.</returns>
/// <exception cref="VersionCheckingException"></exception>
private static AppVersionInfo ParseAppTag(XPathNavigator xpathNav)
{
string name = null;
Version version = null;
string informationalVersion = null;
string description = null;
string downloadUrl = null;
if (xpathNav.MoveToFirstAttribute())
{
do
{
switch (xpathNav.Name)
{
case "name":
name = xpathNav.Value;
break;
case "version":
try
{
version = new Version(xpathNav.Value);
}
catch (Exception ex)
{
throw new VersionCheckingException(VersioningResources.Error_VersionInformation_InvalidVersionsFile_InvalidVersionAttribute, ex);
}
break;
case "informationalVersion":
informationalVersion = xpathNav.Value;
break;
case "description":
description = xpathNav.Value;
break;
case "downloadUrl":
downloadUrl = xpathNav.Value;
break;
}
} while (xpathNav.MoveToNextAttribute());
}
if (version == null)
throw new VersionCheckingException(VersioningResources.Error_VersionInformation_VersionAttributeNotFound);
return new AppVersionInfo(name, version, informationalVersion, description, downloadUrl);
}
示例14: AddAttributeList
private void AddAttributeList(XPathNavigator nav, ArrayList attrs)
{
if (nav.HasAttributes)
{
nav.MoveToFirstAttribute();
do
{
if (!attrs.Contains(nav.Name))
{
attrs.Add(nav.Name);
}
}
while (nav.MoveToNextAttribute());
nav.MoveToParent();
}
}
示例15: TraceContext
internal static void TraceContext(XPathNavigator context) {
string output = "(null)";
if (context != null) {
context = context.Clone ();
switch (context.NodeType) {
case XPathNodeType.Element:
output = string.Format("<{0}:{1}", context.Prefix, context.LocalName);
for (bool attr = context.MoveToFirstAttribute(); attr; attr = context.MoveToNextAttribute()) {
output += string.Format(CultureInfo.InvariantCulture, " {0}:{1}={2}", context.Prefix, context.LocalName, context.Value);
}
output += ">";
break;
default:
break;
}
}
WriteLine(output);
}