本文整理汇总了C#中System.Xml.XmlReader.MoveToNextAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.MoveToNextAttribute方法的具体用法?C# XmlReader.MoveToNextAttribute怎么用?C# XmlReader.MoveToNextAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlReader
的用法示例。
在下文中一共展示了XmlReader.MoveToNextAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: while
void IFlickrParsable.Load(XmlReader reader)
{
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "usage":
Usage = reader.ReadContentAsInt();
break;
case "predicate":
PredicateName = reader.Value;
break;
case "namespace":
NamespaceName = reader.Value;
break;
case "first_added":
DateFirstAdded = UtilityMethods.UnixTimestampToDate(reader.Value);
break;
case "last_added":
DateLastUsed = UtilityMethods.UnixTimestampToDate(reader.Value);
break;
}
}
reader.Read();
if (reader.NodeType == XmlNodeType.Text)
ValueText = reader.ReadContentAsString();
reader.Read();
}
示例2: while
void IFlickrParsable.Load(XmlReader reader)
{
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "id":
PhotoId = reader.Value;
break;
case "ispublic":
IsPublic = reader.Value == "1";
break;
case "iscontact":
IsContact = reader.Value == "1";
break;
case "isfamily":
IsFamily = reader.Value == "1";
break;
case "isfriend":
IsFriend = reader.Value == "1";
break;
}
}
reader.Read();
}
示例3: ReadNodes
public static XmlNode[] ReadNodes(XmlReader xmlReader)
{
if (xmlReader == null)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlReader");
XmlDocument doc = new XmlDocument();
List<XmlNode> nodeList = new List<XmlNode>();
if (xmlReader.MoveToFirstAttribute())
{
do
{
if (IsValidAttribute(xmlReader))
{
XmlNode node = doc.ReadNode(xmlReader);
if (node == null)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnexpectedEndOfFile)));
nodeList.Add(node);
}
} while (xmlReader.MoveToNextAttribute());
}
xmlReader.MoveToElement();
if (!xmlReader.IsEmptyElement)
{
int startDepth = xmlReader.Depth;
xmlReader.Read();
while (xmlReader.Depth > startDepth && xmlReader.NodeType != XmlNodeType.EndElement)
{
XmlNode node = doc.ReadNode(xmlReader);
if (node == null)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnexpectedEndOfFile)));
nodeList.Add(node);
}
}
return nodeList.ToArray();
}
示例4: Parse
public FlatXml Parse(XmlReader reader)
{
var nodes = new SortedSet<FlatXmlNode>();
var position = 0;
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
var element = new FlatXmlNode {Name = reader.Name, Depth = reader.Depth, Position = position};
nodes.Add(element);
if (reader.HasAttributes)
{
while (reader.MoveToNextAttribute())
{
position += 1;
var attribute = new FlatXmlNode {Name = reader.Name, Value = reader.Value, Position = position, Depth = reader.Depth};
nodes.Add(attribute);
}
}
break;
case XmlNodeType.Text:
var t = new FlatXmlNode {Value = reader.Value, Depth = reader.Depth, Position = position};
nodes.Add(t);
break;
}
position += 1;
}
return new FlatXml(nodes);
}
示例5: while
void IFlickrParsable.Load(XmlReader reader)
{
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "id":
this.LicenseId = (LicenseType) reader.ReadContentAsInt();
continue;
case "name":
this.LicenseName = reader.Value;
continue;
case "url":
if (!string.IsNullOrEmpty(reader.Value))
{
this.LicenseUrl = reader.Value;
continue;
}
else
continue;
default:
continue;
}
}
reader.Read();
}
示例6: ProcessEnvelopeNode
public static EsriEnvelope ProcessEnvelopeNode(XmlReader envelopeNode)
{
string realVal;
EsriEnvelope env = new EsriEnvelope();
while (envelopeNode.MoveToNextAttribute())
{
// international numbers
realVal = envelopeNode.Value.Replace(',', '.');
switch (envelopeNode.Name)
{
case "maxx":
env.maxX = double.Parse(realVal);
break;
case "maxy":
env.maxY = double.Parse(realVal);
break;
case "minx":
env.minX = double.Parse(realVal);
break;
case "miny":
env.minY = double.Parse(realVal);
break;
}
}
return env;
}
示例7: ReadXml
public void ReadXml(XmlReader reader)
{
bool isEmpty = reader.IsEmptyElement;
if (reader.HasAttributes)
{
for (int i = 0; i < reader.AttributeCount; i++)
{
reader.MoveToNextAttribute();
if (reader.NamespaceURI == "")
{
if (reader.LocalName == "state")
{
State = reader.Value;
}
else
{
AttributeExtensions.Add(new XmlQualifiedName(reader.LocalName, reader.NamespaceURI), reader.Value);
}
}
}
}
reader.ReadStartElement();
AddElementExtensions(reader, isEmpty);
}
示例8: Load
void IFlickrParsable.Load(XmlReader reader)
{
Load(reader, false);
if (reader.LocalName != "stats")
{
UtilityMethods.CheckParsingException(reader);
}
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "views":
StatViews = int.Parse(reader.Value, NumberFormatInfo.InvariantInfo);
break;
case "comments":
StatComments = int.Parse(reader.Value, NumberFormatInfo.InvariantInfo);
break;
case "favorites":
StatFavorites = int.Parse(reader.Value, NumberFormatInfo.InvariantInfo);
break;
default:
UtilityMethods.CheckParsingException(reader);
break;
}
}
reader.Read();
if (reader.LocalName == "description")
Description = reader.ReadElementContentAsString();
reader.Skip();
}
示例9: while
void IFlickrParsable.Load(XmlReader reader)
{
if (reader.LocalName != "blog")
UtilityMethods.CheckParsingException(reader);
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "id":
BlogId = reader.Value;
break;
case "name":
BlogName = reader.Value;
break;
case "url":
BlogUrl = reader.Value;
break;
case "needspassword":
NeedsPassword = reader.Value == "1";
break;
case "service":
Service = reader.Value;
break;
default:
UtilityMethods.CheckParsingException(reader);
break;
}
}
}
示例10: while
void IFlickrParsable.Load(XmlReader reader)
{
if (!(reader.LocalName != "blog"))
;
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "id":
this.BlogId = reader.Value;
continue;
case "name":
this.BlogName = reader.Value;
continue;
case "url":
this.BlogUrl = reader.Value;
continue;
case "needspassword":
this.NeedsPassword = reader.Value == "1";
continue;
case "service":
this.Service = reader.Value;
continue;
default:
continue;
}
}
}
示例11: AttributeValueElementReadWrite
/// <summary>
/// Creates an instance of the AttributeValue class using the XmlReader and the name of the node that
/// defines the AttributeValue.
/// </summary>
/// <param name="reader">The XmlReader positioned at the node AttributeValue.</param>
/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
public AttributeValueElementReadWrite(XmlReader reader, XacmlVersion schemaVersion)
: base(XacmlSchema.Policy, schemaVersion)
{
if (reader == null) throw new ArgumentNullException("reader");
if (reader.LocalName == Consts.Schema1.AttributeValueElement.AttributeValue &&
ValidateSchema(reader, schemaVersion))
{
if (reader.HasAttributes)
{
// Load all the attributes
while (reader.MoveToNextAttribute())
{
if (reader.LocalName == Consts.Schema1.AttributeValueElement.DataType)
{
_dataType = reader.GetAttribute(Consts.Schema1.AttributeValueElement.DataType);
}
}
reader.MoveToElement();
}
// Load the node contents
_contents = reader.ReadInnerXml();
}
else
{
throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
}
}
示例12: CreateResponseException
public static Exception CreateResponseException(XmlReader reader)
{
if (reader == null)
throw new ArgumentNullException("reader");
reader.MoveToElement();
if (!reader.ReadToDescendant("err"))
throw new XmlException("No error element found in XML");
int code = 0;
string message = (string) null;
while (reader.MoveToNextAttribute())
{
if (reader.LocalName == "code")
{
try
{
code = int.Parse(reader.Value, NumberStyles.Any, (IFormatProvider) NumberFormatInfo.InvariantInfo);
}
catch (FormatException ex)
{
throw new FlickrException("Invalid value found in code attribute. Value '" + (object) code + "' is not an integer");
}
}
else if (reader.LocalName == "msg")
message = reader.Value;
}
return (Exception) ExceptionHandler.CreateException(code, message);
}
示例13: while
void IFlickrParsable.Load(XmlReader reader)
{
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "nsid":
GroupId = reader.Value;
break;
case "name":
GroupName = reader.Value;
break;
case "admin":
IsAdmin = reader.Value == "1";
break;
case "eighteenplus":
EighteenPlus = reader.Value == "1";
break;
case "invitation_only":
InvitationOnly = reader.Value == "1";
break;
default:
UtilityMethods.CheckParsingException(reader);
break;
}
}
reader.Read();
}
示例14: ReadXml
public void ReadXml(XmlReader reader)
{
var isEmpty = reader.IsEmptyElement;
if (reader.HasAttributes)
{
for (var i = 0; i < reader.AttributeCount; i++)
{
reader.MoveToNextAttribute();
if (reader.NamespaceURI == "")
{
if (reader.LocalName == "type")
{
Type = reader.Value;
}
else
{
AttributeExtensions.Add(new XmlQualifiedName(reader.LocalName, reader.NamespaceURI), reader.Value);
}
}
}
}
reader.ReadStartElement();
if (!isEmpty)
{
DescriptionText = reader.ReadContentAsString();
}
reader.ReadEndElement();
}
示例15: ReadXml
public virtual void ReadXml(XmlReader reader)
{
reader.MoveToContent();
if (reader.HasAttributes)
while (reader.MoveToNextAttribute())
AttributeWasRead(reader.Name, reader.Value);
AllAttributesRead();
var isEmpty = reader.IsEmptyElement;
if (!isEmpty)
{
while (reader.Read())
{
var nodeType = reader.NodeType;
switch (nodeType)
{
case XmlNodeType.Text:
var content = reader.ReadContentAsString();
ContentWasRead(string.Empty, content);
break;
case XmlNodeType.Element:
var name = reader.Name;
ProcessElement(name, reader);
break;
}
}
}
}