• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# XmlReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中XmlReader的典型用法代码示例。如果您正苦于以下问题:C# XmlReader类的具体用法?C# XmlReader怎么用?C# XmlReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



XmlReader类属于命名空间,在下文中一共展示了XmlReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AssertNodeValues

		private void AssertNodeValues (
			XmlReader xmlReader,
			XmlNodeType nodeType,
			int depth,
			bool isEmptyElement,
			string name,
			string prefix,
			string localName,
			string namespaceURI,
			string value,
			int attributeCount)
		{
			Assert.AreEqual (nodeType, xmlReader.NodeType, "NodeType");
			Assert.AreEqual (depth, xmlReader.Depth, "Depth");
			Assert.AreEqual (isEmptyElement, xmlReader.IsEmptyElement, "IsEmptyElement");

			Assert.AreEqual (name, xmlReader.Name, "name");

			Assert.AreEqual (prefix, xmlReader.Prefix, "prefix");

			Assert.AreEqual (localName, xmlReader.LocalName, "localName");

			Assert.AreEqual (namespaceURI, xmlReader.NamespaceURI, "namespaceURI");

			Assert.AreEqual ((value != String.Empty), xmlReader.HasValue, "hasValue");

			Assert.AreEqual (value, xmlReader.Value, "Value");

			Assert.AreEqual (attributeCount > 0, xmlReader.HasAttributes, "hasAttributes");

			Assert.AreEqual (attributeCount, xmlReader.AttributeCount, "attributeCount");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:32,代码来源:XmlTextReaderTests.cs


示例2: GetMemberElement

        private static string GetMemberElement(
            FunctionDescriptor function,
            XmlReader xml,
            DocumentElementType property,
            string paramName = "")
        {
            //customNodeDefinitions typedParameters don't have functionDescriptors
            if (function == null)
            {
                return string.Empty;
            }
            var assemblyName = function.Assembly;

            if (string.IsNullOrEmpty(assemblyName))
                return String.Empty;

            var fullyQualifiedName = MemberDocumentNode.MakeFullyQualifiedName
                (assemblyName, GetMemberElementName(function));

            if (!documentNodes.ContainsKey(fullyQualifiedName))
            {
                if (xml == null)
                    xml = DocumentationServices.GetForAssembly(function.Assembly, function.PathManager);
                LoadDataFromXml(xml, assemblyName);
            }

            MemberDocumentNode documentNode = null;
            if (documentNodes.ContainsKey(fullyQualifiedName))
                documentNode = documentNodes[fullyQualifiedName];
            else
            {
                var overloadedName = documentNodes.Keys.
                        Where(key => key.Contains(function.ClassName + "." + function.FunctionName)).FirstOrDefault();

                if (overloadedName == null)
                    return String.Empty;
                if (documentNodes.ContainsKey(overloadedName))
                    documentNode = documentNodes[overloadedName];
            }
            
            if (documentNode == null)
                return String.Empty;
            if (property.Equals(DocumentElementType.Description) && !documentNode.Parameters.ContainsKey(paramName))
                return String.Empty;

            switch (property)
            {
                case DocumentElementType.Summary:
                    return documentNode.Summary;

                case DocumentElementType.Description:
                    return documentNode.Parameters[paramName];

                case DocumentElementType.SearchTags:
                    return documentNode.SearchTags;

                default:
                    throw new ArgumentException("property");
            }
        }
开发者ID:qingemeng,项目名称:Dynamo,代码行数:60,代码来源:XmlDocumentationExtensions.cs


示例3: client_DownloadStringCompleted

        private void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                int itemsCount = 7;
                xmlReader = XmlReader.Create(new StringReader(e.Result));
                feed = SyndicationFeed.Load(xmlReader);

                List<RSSItem> itemsList = new List<RSSItem>();

                if (feed.Items.Count() < 7)
                {
                    itemsCount = feed.Items.Count();
                }

                for (int i = 0; i <= itemsCount; i++)
                {
                    RSSItem rssitem = new RSSItem();
                    rssitem.RSSTitle = feed.Items.ToList()[i].Title.Text;
                    rssitem.RSSLink = feed.Items.ToList()[i].Links[0].Uri;
                    itemsList.Add(rssitem);
                }
                RSS.ItemsSource = itemsList;
            }
        }
开发者ID:coreyperkins,项目名称:Kendor-Site,代码行数:25,代码来源:RSSReader.xaml.cs


示例4: DnaXmlValidator

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="xml">XML to validate</param>
        /// <param name="schemaUri">Schema Uri</param>
        public DnaXmlValidator(string xml, string schemaUri)
        {
            _schemaUri = schemaUri;
            // set up the schema
            LoadSchema(schemaUri);

            // set up the xml reader
            _rawXml = xml;
            _xml = new StringReader(xml);

            // set up the settings for validating the xml
            _validationSettings = new XmlReaderSettings();
            _validationSettings.Schemas.Add(_xmlSchema);
            _validationSettings.IgnoreWhitespace = true;
            _validationSettings.ValidationFlags |= XmlSchemaValidationFlags.ProcessSchemaLocation;
            _validationSettings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
            _validationSettings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema;
            _validationSettings.ValidationType = ValidationType.Schema;
            try
            {
                _validationSettings.Schemas.Compile();
            }
            catch (XmlSchemaException e)
            {
                string s = e.SourceUri;
            }
            _validationSettings.ValidationEventHandler += new ValidationEventHandler(xmlReaderSettingsValidationEventHandler);
            _validationSettings.DtdProcessing = DtdProcessing.Parse;
            // set the the XmlReader for validation
            _validator = XmlReader.Create(_xml, _validationSettings);
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:36,代码来源:DnaXmlValidator.cs


示例5: CanRead

		public override bool CanRead (XmlReader reader)
		{
			if (reader == null)
				throw new ArgumentNullException ("reader");
			reader.MoveToContent ();
			return reader.LocalName == "service" && reader.NamespaceURI == Version;
		}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:AtomPub10ServiceDocumentFormatter.cs


示例6: createPlayer

 void createPlayer(XmlReader reader)
 {
     Vector2 pos = Vector2.Zero;
     TextureMap t = new TextureMap();
     while (reader.Read())
     {
         if (reader.NodeType == XmlNodeType.Element)
         {
             switch (reader.Name)
             {
                 case "position":
                     {
                         reader.ReadToDescendant("x");
                         float x = (float)float.Parse((reader.GetAttribute(0)));
                         reader.ReadToNextSibling("y");
                         float y = (float)float.Parse((reader.GetAttribute(0)));
                         pos = new Vector2(x, y);
                     }
                     break;
                 default:
                     int o = 0;//fer teh deboog
                     break;
             }
         }
     }
     Player p = new Player(pos, t);
 }
开发者ID:CodeMajik,项目名称:RPG,代码行数:27,代码来源:XmlParser.cs


示例7: AssertStartDocument

		// copy from XmlTextReaderTests
		private void AssertStartDocument (XmlReader xmlReader)
		{
			Assert.IsTrue (xmlReader.ReadState == ReadState.Initial);
			Assert.IsTrue (xmlReader.NodeType == XmlNodeType.None);
			Assert.IsTrue (xmlReader.Depth == 0);
			Assert.IsTrue (!xmlReader.EOF);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:8,代码来源:XmlReaderCommonTests.cs


示例8: AssertNodeValues

		private void AssertNodeValues (
			XmlReader xmlReader,
			XmlNodeType nodeType,
			int depth,
			bool isEmptyElement,
			string name,
			string prefix,
			string localName,
			string namespaceURI,
			string value,
			int attributeCount)
		{
			AssertEquals ("NodeType", nodeType, xmlReader.NodeType);
			AssertEquals ("Depth", depth, xmlReader.Depth);
			AssertEquals ("IsEmptyElement", isEmptyElement, xmlReader.IsEmptyElement);

			AssertEquals ("name", name, xmlReader.Name);

			AssertEquals ("prefix", prefix, xmlReader.Prefix);

			AssertEquals ("localName", localName, xmlReader.LocalName);

			AssertEquals ("namespaceURI", namespaceURI, xmlReader.NamespaceURI);

			AssertEquals ("hasValue", (value != String.Empty), xmlReader.HasValue);

			AssertEquals ("Value", value, xmlReader.Value);

			AssertEquals ("hasAttributes", attributeCount > 0, xmlReader.HasAttributes);

			AssertEquals ("attributeCount", attributeCount, xmlReader.AttributeCount);
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:32,代码来源:XmlTextReaderTests.cs


示例9: ValidateXml

        public static bool ValidateXml(XmlReader reader, string customSchema, Action<string> warning, Action<string> error)
        {
            bool isValid = true;

            var schemas = GetSchemas();

            if (customSchema != null)
            {
                schemas.Add(null, XmlReader.Create(customSchema));
            }

            ValidationEventHandler handler = (s, args) =>
            {
                isValid = false;
                if (warning != null && args.Severity == XmlSeverityType.Warning)
                    warning(args.Message);
                else if (error != null)
                    error(args.Message);
            };

            var settings = new XmlReaderSettings();
            settings.ValidationType = ValidationType.Schema;
            settings.Schemas.Add(schemas);
            settings.ValidationEventHandler += handler;

            var r = XmlReader.Create(reader, settings);
            while (r.Read()) ;

            return isValid;
        }
开发者ID:dur41d,项目名称:sdmxdotnet,代码行数:30,代码来源:MessageValidator.cs


示例10: ClientData

        private ClientData(XmlReader reader)
        {
            reader.ReadStartElement("ClientData");

            for (int iter = 0; iter < _NumStoredValues; iter++) {

                reader.ReadStartElement(_StoredValueNames[iter]);

                if (_StoredValues[iter] is string)
                    _StoredValues[iter] = reader.ReadContentAsString();
                else if (_StoredValues[iter] is DateTime) {
                    string s = reader.ReadContentAsString();
                    long l = long.Parse(s, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
                    _StoredValues[iter] = DateTime.FromFileTimeUtc(l);
                } else if (_StoredValues[iter] is bool) {
                    string s = reader.ReadContentAsString();
                    _StoredValues[iter] = !(string.IsNullOrEmpty(s) || s != "1");
                } else {
                    _StoredValues[iter] = ReadStringArray(reader);
                }
                reader.ReadEndElement();
            }

            reader.ReadEndElement();
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:25,代码来源:ClientData.cs


示例11: LoadFromXml

		public void LoadFromXml (XmlReader reader)
		{
			reader.ReadToDescendant ("plist");
			while (reader.Read () && reader.NodeType != XmlNodeType.Element);
			if (!reader.EOF)
				root = LoadFromNode (reader);
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:7,代码来源:PlistDocument.cs


示例12: ParseCategories

        /// <summary>tries to parse a category collection document</summary> 
        /// <param name="reader"> xmlReader positioned at the start element</param>
        /// <param name="owner">the base object that the collection belongs to</param>
        /// <returns></returns>
        public AtomCategoryCollection ParseCategories(XmlReader reader, AtomBase owner) {
            Tracing.Assert(reader != null, "reader should not be null");
            if (reader == null) {
                throw new ArgumentNullException("reader");
            }
            AtomCategoryCollection ret = new AtomCategoryCollection();
            MoveToStartElement(reader);

            Tracing.TraceCall("entering Categories Parser");
            object localname = reader.LocalName;
            Tracing.TraceInfo("localname is: " + reader.LocalName);

            if (IsCurrentNameSpace(reader, BaseNameTable.AppPublishingNamespace(owner)) &&
                localname.Equals(this.nameTable.Categories)) {
                Tracing.TraceInfo("Found categories  document");
                int depth = -1;
                while (NextChildElement(reader, ref depth)) {
                    localname = reader.LocalName;
                    if (IsCurrentNameSpace(reader, BaseNameTable.NSAtom)) {
                        if (localname.Equals(this.nameTable.Category)) {
                            AtomCategory category = ParseCategory(reader, owner);
                            ret.Add(category);
                        }
                    }
                }
            } else {
                Tracing.TraceInfo("ParseCategories called and nothing was parsed" + localname);
                throw new ClientFeedException("An invalid Atom Document was passed to the parser. This was not an app:categories document: " + localname);
            }

            return ret;
        }
开发者ID:risetech,项目名称:work.rise-tech.com,代码行数:36,代码来源:atomfeedparser.cs


示例13: GenerateCode

 private static string GenerateCode(XmlReader reader, string nameSpace)
 {
     EntityClassGenerator generator = new EntityClassGenerator(LanguageOption.GenerateCSharpCode) {
         Version = DataServiceCodeVersion.V2
     };
     StringWriter targetWriter = new StringWriter();
     try
     {
         IList<EdmSchemaError> list = generator.GenerateCode(reader, targetWriter, nameSpace);
         if (list.Count > 0)
         {
             throw new DisplayToUserException(string.Concat(new object[] { "Bad schema: ", list[0].Message, " (line ", list[0].Line, ")" }));
         }
     }
     catch (MetadataException exception)
     {
         throw new DisplayToUserException("MetadataException: " + exception.Message);
     }
     catch (XmlSchemaValidationException exception2)
     {
         throw new DisplayToUserException("This schema is unsupported.\r\n\r\nEntityClassGenerator returned the following error: " + exception2.Message);
     }
     catch (FileNotFoundException exception3)
     {
         if (exception3.Message.Contains("System.Data.Services.Design"))
         {
             throw new DisplayToUserException("Cannot load System.Data.Services.Design.dll. (A possible cause is installing only the .NET Framework Client Profile instead of the full .NET Framework.)");
         }
         throw;
     }
     return targetWriter.ToString();
 }
开发者ID:CuneytKukrer,项目名称:TestProject,代码行数:32,代码来源:AstoriaHelper.cs


示例14: DeserializeResponse

 public XmlRpcResponse DeserializeResponse(XmlReader rdr, Type returnType)
 {
     try
     {
         IEnumerator<Node> enumerator = new XmlRpcParser().ParseResponse(rdr).GetEnumerator();
         enumerator.MoveNext();
         if (enumerator.Current is FaultNode)
             throw DeserializeFault(enumerator);
         if (returnType == typeof (void) || !enumerator.MoveNext())
         {
             return new XmlRpcResponse
                    {
                        retVal = null
                    };
         }
         Node current = enumerator.Current;
         object obj = MapValueNode(enumerator, returnType, new MappingStack("response"), MappingAction.Error);
         return new XmlRpcResponse
                {
                    retVal = obj
                };
     }
     catch (XmlException ex)
     {
         throw new XmlRpcIllFormedXmlException("Response contains invalid XML", ex);
     }
 }
开发者ID:ChrisASearles,项目名称:Infusionsoft.net,代码行数:27,代码来源:XmlRpcResponseDeserializer.cs


示例15: DeserializeElement

 protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey)
 {
     base.DeserializeElement(reader, serializeCollectionKey);
     WebContext hostingContext = base.EvaluationContext.HostingContext as WebContext;
     if ((hostingContext != null) && (this.Href.Length != 0))
     {
         string path = hostingContext.Path;
         string configurationDirectory = null;
         if (path == null)
         {
             path = HostingEnvironment.ApplicationVirtualPath;
             if (path == null)
             {
                 path = "";
             }
             configurationDirectory = this.GetConfigurationDirectory();
         }
         else
         {
             configurationDirectory = HostingEnvironment.MapPath(path);
         }
         if (!path.EndsWith("/", StringComparison.Ordinal))
         {
             path = path + "/";
         }
         CheckIOReadPermission(configurationDirectory, this.Href);
         this.actualPath = configurationDirectory;
         this.virtualPath = path;
         this.needToValidateHref = true;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:WsdlHelpGeneratorElement.cs


示例16: CreateReader

 public static XmlReader CreateReader(XmlReader baseReader, WhitespaceRuleLookup wsRules)
 {
     if (wsRules == null)
     {
         return baseReader;    // There is no rules to process
     }
     XmlReaderSettings readerSettings = baseReader.Settings;
     if (readerSettings != null)
     {
         if (readerSettings.IgnoreWhitespace)
         {
             return baseReader;        // V2 XmlReader that strips all WS
         }
     }
     else
     {
         XmlTextReader txtReader = baseReader as XmlTextReader;
         if (txtReader != null && txtReader.WhitespaceHandling == WhitespaceHandling.None)
         {
             return baseReader;        // V1 XmlTextReader that strips all WS
         }
         XmlTextReaderImpl txtReaderImpl = baseReader as XmlTextReaderImpl;
         if (txtReaderImpl != null && txtReaderImpl.WhitespaceHandling == WhitespaceHandling.None)
         {
             return baseReader;        // XmlTextReaderImpl that strips all WS
         }
     }
     return new WhitespaceRuleReader(baseReader, wsRules);
 }
开发者ID:chcosta,项目名称:corefx,代码行数:29,代码来源:WhitespaceRuleReader.cs


示例17: InternalDeserializer

 internal InternalDeserializer(XmlReader reader, DeserializationContext context)
 {
     this._reader = reader;
     this._context = context;
     this.objectRefIdHandler = new ReferenceIdHandlerForDeserializer<object>();
     this.typeRefIdHandler = new ReferenceIdHandlerForDeserializer<ConsolidatedString>();
 }
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:InternalDeserializer.cs


示例18: Read

 public static WebReferenceOptions Read(XmlReader xmlReader, ValidationEventHandler validationEventHandler)
 {
     WebReferenceOptions options;
     XmlValidatingReader reader = new XmlValidatingReader(xmlReader) {
         ValidationType = ValidationType.Schema
     };
     if (validationEventHandler != null)
     {
         reader.ValidationEventHandler += validationEventHandler;
     }
     else
     {
         reader.ValidationEventHandler += new ValidationEventHandler(WebReferenceOptions.SchemaValidationHandler);
     }
     reader.Schemas.Add(Schema);
     webReferenceOptionsSerializer serializer = new webReferenceOptionsSerializer();
     try
     {
         options = (WebReferenceOptions) serializer.Deserialize(reader);
     }
     catch (Exception exception)
     {
         throw exception;
     }
     finally
     {
         reader.Close();
     }
     return options;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:WebReferenceOptions.cs


示例19: XmlConfigFile

 /// <summary>Initializes a new instance of the XmlConfigFile
 /// class.</summary>
 /// <param name='reader'>A XmlReader object.</param>
 /// <param name='rootElement'>A string object.</param>
 /// <exception cref='ArgumentNullException'>The parameter <paramref
 /// name='reader'/> is null.</exception>
 private XmlConfigFile(XmlReader reader, string rootElement)
 {
     if (reader == null) {
     throw new ArgumentNullException("reader");
       }
       if (rootElement.Length == 0) {
     throw new ArgumentException("'rootElement' is empty.");
       }
       XmlDocument doc;
       try {
     doc = new XmlDocument();
     doc.Load(reader);
       } catch (IOException e) {
     throw new XmlConfigException(e.Message, e);
       } catch (UnauthorizedAccessException e) {
     throw new XmlConfigException(e.Message, e);
       } catch (XmlException e) {
     throw new XmlConfigException(e.Message, e);
       }
       if (doc.DocumentElement == null) {
     throw new XmlConfigException("The file contains no XML element.");
       }
       if (rootElement != null && !doc.DocumentElement.Name.Equals(rootElement))
     throw new XmlConfigException(
       ("The XML file's root element is " + doc.DocumentElement.Name +
     ", not " + rootElement + "."));
       this.Initialize(doc.DocumentElement);
 }
开发者ID:peteroupc,项目名称:Fuzzer,代码行数:34,代码来源:XmlConfigFile.cs


示例20: MappingOption

 public MappingOption(XmlReader xml)
 {
     Schema = xml.GetAttribute("Schema");
     Prefix = xml.GetAttribute("Prefix");
     Class = xml.GetAttribute("Class");
     Pattern = xml.GetAttribute("Pattern");
 }
开发者ID:nicknystrom,项目名称:NSprocs,代码行数:7,代码来源:Options.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# XmlReaderSettings类代码示例发布时间:2022-05-24
下一篇:
C# XmlQueryType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap