本文整理汇总了C#中System.Xml.XmlReader.IsStartElement方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.IsStartElement方法的具体用法?C# XmlReader.IsStartElement怎么用?C# XmlReader.IsStartElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlReader
的用法示例。
在下文中一共展示了XmlReader.IsStartElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadXml
protected virtual void ReadXml(XmlReader reader, SyndicationFeed result)
{
if (result == null)
throw new ArgumentNullException("result");
else if (reader == null)
throw new ArgumentNullException("reader");
reader.ReadStartElement(); // Read in <RDF>
reader.ReadStartElement("channel"); // Read in <channel>
while (reader.IsStartElement()) // Process <channel> children
{
if (reader.IsStartElement("title"))
result.Title = new TextSyndicationContent(reader.ReadElementString());
else if (reader.IsStartElement("link"))
result.Links.Add(new SyndicationLink(new Uri(reader.ReadElementString())));
else if (reader.IsStartElement("description"))
result.Description = new TextSyndicationContent(reader.ReadElementString());
else
reader.Skip();
}
reader.ReadEndElement(); // Read in </channel>
while (reader.IsStartElement())
{
if (reader.IsStartElement("item"))
{
result.Items = this.ReadItems(reader, result);
break;
}
else
reader.Skip();
}
}
示例2: DeserializeAnalyticsSettings
/// <summary>
/// Reads the settings provided from stream
/// </summary>
/// <param name="xmlReader"></param>
/// <returns></returns>
public static AnalyticsSettings DeserializeAnalyticsSettings(XmlReader xmlReader)
{
// Read the root and check if it is empty or invalid xmlReader.Read();
xmlReader.ReadStartElement(SettingsSerializerHelper.RootPropertiesElementName);
AnalyticsSettings settings = new AnalyticsSettings();
while (true)
{
if (xmlReader.IsStartElement(SettingsSerializerHelper.LoggingElementName))
{
DeserializeLoggingElement(xmlReader, settings);
}
else if (xmlReader.IsStartElement(SettingsSerializerHelper.MetricsElementName))
{
DeserializeMetricsElement(xmlReader, settings);
}
else
{
break;
}
}
xmlReader.ReadEndElement();
return settings;
}
示例3: ReadMatch
/// <summary>
/// Reads the match.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="reader">The reader.</param>
/// <returns></returns>
/// <exception cref="System.Xml.XmlException">MatchId IsNullOrEmpty</exception>
protected override XacmlMatch ReadMatch(XmlReader reader) {
Contract.Requires<ArgumentNullException>(reader != null, "reader");
Contract.Requires<XmlException>(reader.IsStartElement(XacmlConstants.ElementNames.Match, this.version.NamespacePolicy));
var gaMatchId = reader.GetAttribute("MatchId");
if (string.IsNullOrEmpty(gaMatchId)) {
throw Diagnostic.DiagnosticTools.ExceptionUtil.ThrowHelperError(new XmlException("MatchId IsNullOrEmpty"));
}
reader.ReadStartElement(XacmlConstants.ElementNames.Match, this.version.NamespacePolicy);
var attributeValue = ReadAttributeValue(reader);
XacmlMatch result;
if (reader.IsStartElement(XacmlConstants.ElementNames.AttributeDesignator, this.version.NamespacePolicy)) {
var attributeDesignator = this.ReadAttributeDesignator(reader) as XacmlAttributeDesignator;
result = new XacmlMatch(new Uri(gaMatchId, UriKind.RelativeOrAbsolute), attributeValue, attributeDesignator);
}
else {
XacmlAttributeSelector attributeSelector = ReadAttributeSelector(reader);
result = new XacmlMatch(new Uri(gaMatchId, UriKind.RelativeOrAbsolute), attributeValue, attributeSelector);
}
reader.ReadEndElement();
return result;
}
示例4: ReadXml
/// <summary>
/// Generates an object from its XML representation.
/// </summary>
/// <param name="reader">
/// The <see cref="System.Xml.XmlReader" /> stream from which the object is
/// deserialized.
/// </param>
public void ReadXml(XmlReader reader)
{
if (!reader.IsStartElement("Manager"))
{
throw new XmlException("Expected <Manager> element");
}
bool isEmptyElement = reader.IsEmptyElement;
reader.ReadStartElement("Manager");
if (!isEmptyElement)
{
if (!reader.IsStartElement("Variables"))
{
throw new XmlException("Expected <Variables> subelement in <Manager> element");
}
isEmptyElement = reader.IsEmptyElement;
reader.ReadStartElement("Variables");
if (!isEmptyElement)
{
while (reader.IsStartElement("Variable"))
{
Variable variable = new Variable();
variable.ReadXml(reader);
this.Variables.Add(variable);
}
reader.ReadEndElement(); // Variables
}
reader.ReadEndElement(); // Manager
}
}
示例5: DetermineFileType
private static MetadataFileType DetermineFileType(XmlReader reader)
{
try
{
if (reader.IsStartElement("definitions", "http://schemas.xmlsoap.org/wsdl/"))
{
return MetadataFileType.Wsdl;
}
if (reader.IsStartElement("schema", "http://www.w3.org/2001/XMLSchema"))
{
return MetadataFileType.Xsd;
}
if (reader.IsStartElement("Policy", "http://schemas.xmlsoap.org/ws/2004/09/policy") || reader.IsStartElement("Policy", "http://www.w3.org/ns/ws-policy"))
{
return MetadataFileType.Policy;
}
if (reader.IsStartElement("EndpointReference", "http://schemas.xmlsoap.org/ws/2004/08/addressing"))
{
return MetadataFileType.Epr;
}
return MetadataFileType.UnknownXml;
}
catch (XmlException)
{
return MetadataFileType.NonXml;
}
}
示例6: ReadXml
public void ReadXml(XmlReader reader)
{
int sequenceCount = 0;
bool isEmpty = reader.IsEmptyElement;
reader.ReadStartElement();
if (isEmpty)
return;
while (reader.NodeType == XmlNodeType.Element)
{
if (sequenceCount == 0 || reader.IsStartElement("title"))
{
PitchSequences.Add(new PitchSequence());
sequenceCount++;
}
if (reader.IsStartElement("title"))
PitchSequences[sequenceCount - 1].Title = reader.ReadElementString();
else if (reader.IsStartElement("pitch"))
{
var pitch = new Pitch();
pitch.ReadXml(reader);
PitchSequences[sequenceCount - 1].Pitches.Add(pitch);
}
else
reader.ReadOuterXml();
}
reader.ReadEndElement();
}
示例7: ReadKeyIdentifierCore
protected override SecurityKeyIdentifier ReadKeyIdentifierCore(XmlReader reader)
{
var result = new SecurityKeyIdentifier();
reader.ReadStartElement("KeyInfo", SignedXml.XmlDsigNamespaceUrl);
while (reader.IsStartElement())
{
if (reader.IsStartElement("X509Data", SignedXml.XmlDsigNamespaceUrl))
{
foreach (var clause in ReadX509Data(reader))
{
result.Add(clause);
}
}
else
{
if (reader.IsStartElement("KeyName", SignedXml.XmlDsigNamespaceUrl))
{
result.Add(ReadKeyNameClause(reader));
}
else
{
reader.Skip();
}
}
}
reader.ReadEndElement();
return result;
}
示例8: Deserialize
//public static Oids.Oid Deserialize(XmlReader reader, Oids.Oid oid)
/// <summary>
/// Deserializes Oid from an XML stream.
/// </summary>
/// <param name="reader">XML stream.</param>
/// <returns>Oid.</returns>
public static Oids.Oid Deserialize(XmlReader reader)
{
Oids.Oid lResult = null;
if (reader.IsStartElement(DTD.TagOID))
{
string lClassName = reader.GetAttribute(DTD.OID.TagClass);
List<KeyValuePair<ModelType,object>> lFields = new List<KeyValuePair<ModelType,object>>();
if (!reader.IsEmptyElement)
{
reader.ReadStartElement();
do
{
#region Process tag <OID.Field>.
if (reader.IsStartElement(DTD.OID.TagOIDField))
{
if (!reader.IsEmptyElement)
{
ModelType lType = Convert.StringTypeToMODELType(reader.GetAttribute(DTD.OID.TagType));
lFields.Add(new KeyValuePair<ModelType, object>(lType, Convert.XmlToType(lType, reader.ReadString())));
}
else
{
throw new ArgumentException("Xml Reader have one OID.Field with empty Element.", "XmlReader reader");
}
}
#endregion Process tag <OID.Field>.
else
{
#region Process tag <?>
reader.Skip();
if (reader.NodeType == XmlNodeType.None)
{
break;
}
else
{
continue;
}
#endregion Process tag <?>
}
} while (reader.Read());
}
else
{
reader.Skip();
}
if(lClassName.Length > 0)
{
lResult = ServerConnection.CreateOid(lClassName,lFields);
}
}
else
{
throw new ArgumentException("Xml Reader don't have the OID in Start Element.", "XmlReader reader");
}
return lResult;
}
示例9: Deserialize
public static ServiceResponse Deserialize(XmlReader reader, ServiceResponse serviceResponse)
{
if (reader.IsStartElement(DTD.Response.TagServiceResponse))
{
if (serviceResponse == null)
{
serviceResponse = new ServiceResponse();
}
if (!reader.IsEmptyElement)
{
reader.ReadStartElement();
do
{
#region <ERROR>
if (reader.IsStartElement(DTD.Response.ServiceResponse.TagError))
{
if(int.Parse(reader.GetAttribute(DTD.Error.TagNumber))!=0)
{
throw XMLErrorSerializer.Deserialize(reader.ReadSubtree());
}
else
{
reader.Skip();
}
}
#endregion <ERROR>
#region <OID>
if (reader.IsStartElement(DTD.TagOID))
{
serviceResponse.Oid = XMLAdaptorOIDSerializer.Deserialize(reader.ReadSubtree());
}
#endregion <OID>
#region <Arguments>
if (reader.IsStartElement(DTD.Response.ServiceResponse.TagArguments))
{
serviceResponse.Arguments = XMLArgumentsSerializer.Deserialize(reader.ReadSubtree());
}
#endregion <Arguments>
} while (reader.Read());
}
else
{
reader.Skip();
}
}
else
{
throw new ArgumentException("Xml Reader don't have the Service.Response in Start Element.", "XmlReader reader");
}
return serviceResponse;
}
示例10: ReadXmlElement
/// <summary>
/// Override of the base class that reads a child element inside the RST
/// </summary>
/// <param name="reader">Reader pointing at an element to read inside the RST.</param>
/// <param name="rst">The RequestSecurityToken element that is being populated from the reader.</param>
/// <param name="context">Current Serialization context.</param>
/// <exception cref="ArgumentNullException">Either reader or rst or context parameter is null.</exception>
/// <exception cref="WSTrustSerializationException">Unable to deserialize the current parameter.</exception>
public override void ReadXmlElement(XmlReader reader, RequestSecurityToken rst, WSTrustSerializationContext context)
{
if (reader == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
if (rst == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("rst");
}
if (context == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
}
// special case SecondaryParameters, they cannot be embeded as per WS-Trust 1.3
if (reader.IsStartElement(WSTrust13Constants.ElementNames.SecondaryParameters, WSTrust13Constants.NamespaceURI))
{
rst.SecondaryParameters = this.ReadSecondaryParameters(reader, context);
return;
}
if (reader.IsStartElement(WSTrust13Constants.ElementNames.KeyWrapAlgorithm, WSTrust13Constants.NamespaceURI))
{
rst.KeyWrapAlgorithm = reader.ReadElementContentAsString();
if (!UriUtil.CanCreateValidUri(rst.KeyWrapAlgorithm, UriKind.Absolute))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WSTrustSerializationException(SR.GetString(SR.ID3135, WSTrust13Constants.ElementNames.KeyWrapAlgorithm, WSTrust13Constants.NamespaceURI, rst.KeyWrapAlgorithm)));
}
return;
}
if (reader.IsStartElement(WSTrust13Constants.ElementNames.ValidateTarget, WSTrust13Constants.NamespaceURI))
{
if (!reader.IsEmptyElement)
{
rst.ValidateTarget = new SecurityTokenElement(WSTrustSerializationHelper.ReadInnerXml(reader), context.SecurityTokenHandlers);
}
if (rst.ValidateTarget == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WSTrustSerializationException(SR.GetString(SR.ID3221)));
}
return;
}
WSTrustSerializationHelper.ReadRSTXml(reader, rst, context, WSTrustConstantsAdapter.Trust13);
}
示例11: PackDefinition
public PackDefinition(XmlReader reader)
{
Items = new List<IPackItem>();
while (true)
{
if (reader.IsStartElement("pick"))
Items.Add(new Pick(reader));
else if (reader.IsStartElement("options"))
Items.Add(new OptionsList(reader));
else
return;
}
}
示例12: GetFeedFactory
private static FeedFactory GetFeedFactory(XmlReader reader) {
if (reader.IsStartElement("rss", String.Empty) ||
reader.IsStartElement("rdf:RDF")) {
return new RssFeedFactory();
}
if (reader.IsStartElement("atom", "http://www.w3.org/2005/Atom") ||
reader.IsStartElement("feed", "http://www.w3.org/2005/Atom")) {
return new AtomFeedFactory();
}
return null;
}
示例13: Read
/// <summary>
/// Reads the next blueprint from the specified reader.
/// </summary>
/// <param name="reader">Reader to read the next blueprint from.</param>
/// <returns>Read blueprint.</returns>
public Blueprint Read(XmlReader reader)
{
reader.Read();
reader.Read();
var blueprintId = reader[BlueprintIdAttributeName];
var blueprint = new Blueprint(blueprintId);
// Read blueprint id.
reader.ReadStartElement(BlueprintElementName);
{
// Read property values.
reader.ReadStartElement(PropertyValuesElementName);
{
while (reader.IsStartElement(PropertyElementName))
{
var key = reader[PropertyKeyAttributeName];
var typeName = reader[PropertyTypeAttributeName];
var type = Type.GetType(typeName);
reader.ReadStartElement(PropertyElementName);
{
var value =
new XmlSerializer(type, new XmlRootAttribute(PropertyValueElementName)).Deserialize(
reader);
// Add to blueprint.
blueprint.PropertyValues.Add(key, value);
}
reader.ReadEndElement();
}
}
reader.ReadEndElement();
// Read components.
reader.ReadStartElement(ComponentsElementName);
{
while (reader.IsStartElement(ComponentElementName))
{
var component = reader.ReadElementContentAsString();
// Add to blueprint.
blueprint.ComponentTypes.Add(component);
}
}
reader.ReadEndElement();
}
reader.ReadEndElement();
return blueprint;
}
示例14: Deserialize
/// <summary>
/// Deserializes an ChangedItem from an XML file.
/// </summary>
/// <param name="reader">XMLReader where the ChangedItem is.</param>
/// <returns>ChangedItem.</returns>
public static ChangedItem Deserialize(XmlReader reader)
{
ChangedItem lResult = null;
if (reader.IsStartElement(DTD.Error.ChangedItems.TagChangedItem))
{
lResult = new ChangedItem();
string stringModelType = reader.GetAttribute(DTD.Error.ChangedItems.ChangedItem.TagType);
ModelType modelType = Convert.StringTypeToMODELType(stringModelType);
if (modelType == ModelType.Oid)
{
lResult.Type = Convert.MODELTypeToStringType(ModelType.Oid);
lResult.ClassName = stringModelType;
}
else
{
lResult.Type = stringModelType;
lResult.ClassName = string.Empty;
}
lResult.Name = reader.GetAttribute(DTD.Error.ChangedItems.ChangedItem.TagName);
if (!reader.IsEmptyElement)
{
reader.ReadStartElement();
if (reader.IsStartElement(DTD.Error.ChangedItems.ChangedItem.TagChangedItemOldValue))
{
lResult.OldValue = XMLChangedItemValueSerializer.Deserialize(reader.ReadSubtree(),lResult.Type, lResult.ClassName);
reader.ReadEndElement();
}
if (reader.IsStartElement(DTD.Error.ChangedItems.ChangedItem.TagChangedItemNewValue))
{
lResult.NewValue = XMLChangedItemValueSerializer.Deserialize(reader.ReadSubtree(), lResult.Type, lResult.ClassName);
reader.ReadEndElement();
}
}
else
{
reader.Skip();
}
}
else
{
throw new ArgumentException("Xml Reader don't have the ChangedItem in Start Element.", "XmlReader reader");
}
return lResult;
}
示例15: Decode
/// <summary>
/// Decodes an <see cref="Error"/> object from its XML representation.
/// </summary>
public static Error Decode(XmlReader reader)
{
if (reader == null) throw new ArgumentNullException("reader");
if (!reader.IsStartElement()) throw new ArgumentException("Reader is not positioned at the start of an element.", "reader");
//
// Read out the attributes that contain the simple
// typed state.
//
var error = new Error();
ReadXmlAttributes(reader, error);
//
// Move past the element. If it's not empty, then
// read also the inner XML that contains complex
// types like collections.
//
var isEmpty = reader.IsEmptyElement;
reader.Read();
if (!isEmpty)
{
ReadInnerXml(reader, error);
reader.ReadEndElement();
}
return error;
}