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

C# Xml.XmlParserContext类代码示例

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

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



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

示例1: Constructor2

		public void Constructor2 ()
		{
			XmlDocument doc = new XmlDocument ();
			XmlNamespaceManager ns = new XmlNamespaceManager (doc.NameTable);

			XmlParserContext pc = new XmlParserContext (doc.NameTable,
				ns, "dunno", XmlSpace.None, Encoding.UTF8);
			Assert.AreEqual (string.Empty, pc.BaseURI, "#A1");
			Assert.AreEqual (string.Empty, pc.DocTypeName, "#A2");
			Assert.AreEqual (Encoding.UTF8, pc.Encoding, "#A3");
			Assert.AreEqual (string.Empty, pc.InternalSubset, "#A4");
			Assert.AreSame (ns, pc.NamespaceManager, "#A5");
			Assert.AreSame (doc.NameTable, pc.NameTable, "#A6");
			Assert.AreEqual (string.Empty, pc.PublicId, "#A7");
			Assert.AreEqual (string.Empty, pc.SystemId, "#A8");
			Assert.AreEqual ("dunno", pc.XmlLang, "#A9");
			Assert.AreEqual (XmlSpace.None, pc.XmlSpace, "#A10");

			pc = new XmlParserContext ((NameTable) null, (XmlNamespaceManager) null,
				(string) null, XmlSpace.None, (Encoding) null);
			Assert.AreEqual (string.Empty, pc.BaseURI, "#B1");
			Assert.AreEqual (string.Empty, pc.DocTypeName, "#B2");
			Assert.IsNull (pc.Encoding, "#B3");
			Assert.AreEqual (string.Empty, pc.InternalSubset, "#B4");
			Assert.IsNull (pc.NamespaceManager, "#B5");
			Assert.IsNull (pc.NameTable, "#B6");
			Assert.AreEqual (string.Empty, pc.PublicId, "#B7");
			Assert.AreEqual (string.Empty, pc.SystemId, "#B8");
			Assert.AreEqual (string.Empty, pc.XmlLang, "#B9");
			Assert.AreEqual (XmlSpace.None, pc.XmlSpace, "#B10");
		}
开发者ID:nobled,项目名称:mono,代码行数:31,代码来源:XmlParserContextTests.cs


示例2: ExtractQuery

        public static string ExtractQuery(string fileName, TextWriter errorlogger)
        {
            try
            {
                string data = File.ReadAllText(fileName);
                XmlParserContext context = new XmlParserContext(null, null, null, XmlSpace.None);
                Stream xmlFragment = new MemoryStream(Encoding.UTF8.GetBytes(data));
                XmlTextReader reader = new XmlTextReader(xmlFragment, XmlNodeType.Element, context);
                reader.MoveToContent();
                if (reader.NodeType == XmlNodeType.Text)
                {
                    return data;
                }
                XmlReader reader2 = reader.ReadSubtree();
                StringBuilder output = new StringBuilder();
                using (XmlWriter writer = XmlWriter.Create(output))
                {
                    writer.WriteNode(reader2, true);
                }

                StringReader reader3 = new StringReader(data);
                for (int i = 0; i < reader.LineNumber; i++)
                {
                    reader3.ReadLine();
                }
                return reader3.ReadToEnd().Trim();
            }
            catch (Exception ex)
            {
                errorlogger.WriteLine(ex.Message);
                errorlogger.WriteLine(ex.StackTrace);
            }

            return string.Format("//Error loading the file - {0} .The the linq file might be a linqpad expression which is not supported in the viewer currently." ,fileName);
        }
开发者ID:aelij,项目名称:svcperf,代码行数:35,代码来源:LinqpadHelpers.cs


示例3: GetIssueListFromXmlStream

        public static List<Issue> GetIssueListFromXmlStream(Stream stream) {
            List<Issue> issues = new List<Issue>();
            XmlTextReader reader = new XmlTextReader(stream);
            XmlDocument doc = new XmlDocument();
            doc.Load(reader);
            reader.Close();
            XmlNodeList list = doc.DocumentElement.GetElementsByTagName("item");
            XmlSerializer s = new XmlSerializer(typeof(Issue));
            //Create the XmlNamespaceManager.
            NameTable nt = new NameTable();
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
            nsmgr.AddNamespace("jc", "urn:jiraconn");

            //Create the XmlParserContext.
            XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);

            foreach (XmlNode item in list)
            {
                //Create the reader. 
                XmlTextReader itemReader = new XmlTextReader(item.OuterXml, XmlNodeType.Element, context);
                Issue issue = (Issue)s.Deserialize(itemReader);
                issues.Add(issue);
            }

            return issues;
            
        }
开发者ID:Dashboard-X,项目名称:JIRA_Connector_1.0.0_Beta_1,代码行数:27,代码来源:JiraXMLHelper.cs


示例4: RenderComponentFieldAsBBCode

        public string RenderComponentFieldAsBBCode(string fieldExpression, int fieldIndex, bool outputImages)
        {
            BuiltInFunctions functions = new BuiltInFunctions(_engine, _package);
            string output = functions.RenderComponentField(fieldExpression, fieldIndex);

            StringReader sr = new StringReader(output);
            NameTable nt = new NameTable();
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
            nsmgr.AddNamespace("tcdl", Tridion.ContentManager.Templating.TcdlTags.TcdlNamespace);
            XmlParserContext parserContext = new XmlParserContext(null, nsmgr, null, XmlSpace.None);

            XmlReader xmlReader = XmlReader.Create(sr, new XmlReaderSettings(), parserContext);

            XslCompiledTransform transform = new XslCompiledTransform(true);

            using (Stream xsltStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Tridion.ContentManager.Templating.Expression.NetbiscuitsFunctions.XhtmlToBBCode.xslt"))
            {
                using (XmlReader xsltReader = XmlReader.Create(xsltStream))
                {
                    transform.Load(xsltReader);
                }
            }

            StringWriter resultWriter = new StringWriter();
            XsltArgumentList argumentList = new XsltArgumentList();
            argumentList.AddParam("IncludeImages", String.Empty, outputImages);

            transform.Transform(xmlReader, argumentList, resultWriter);

            return resultWriter.ToString();   
        }
开发者ID:SGAnonymous,项目名称:sdl-tridion-world,代码行数:31,代码来源:NetbiscuitsFunctions.cs


示例5: Validate

        /// <summary>
        /// Validates XML definition against given XSD schema.
        /// </summary>
        /// <param name="xmlFileName">Full path to the XML file on file system.</param>
        /// <param name="schemaContent">XSD schema.</param>
        /// <param name="schemaName">XSD schema name.</param>
        public void Validate(string xmlFileName, string schemaContent, string schemaName)
        {
            _xmlFileName = xmlFileName;

            var xmlDoc = GetUpdatedXml(xmlFileName, schemaName);
            var xmlSchemaSet = GetXmlSchema(schemaContent, schemaName);

            var nt = new NameTable();
            var nsmgr = new XmlNamespaceManager(nt);
            var context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);

            var settings = new XmlReaderSettings();
            settings.ValidationType = ValidationType.Schema;
            settings.Schemas.Add(xmlSchemaSet);
            settings.ValidationEventHandler += ValidationCallbackOne;

            using (var xmlr = new XmlTextReader(xmlDoc.OuterXml, XmlNodeType.Document, context))
            {
                using (var reader = XmlReader.Create(xmlr, settings))
                {
                    while (reader.Read())
                    {
                        var val = reader.Value;
                    }
                }
            }
        }
开发者ID:vegaitsourcing,项目名称:dbupgrade,代码行数:33,代码来源:XmlValidator.cs


示例6: nodeSet

		/// <summary>
		/// Implements the following function
		/// node-set exsl:node-set(object)
		/// </summary>
		/// <param name="o"></param>
		/// <returns></returns>        
        public XPathNodeIterator nodeSet(object o) 
        {		
            if (o is XPathNavigator) 
            {
                XPathNavigator nav = (XPathNavigator)o;		        
                if (selectItself == null)
                    selectItself = nav.Compile(".");                                    
                return nav.Select(selectItself.Clone());
            } 
            else if (o is XPathNodeIterator)
                return o as XPathNodeIterator;
            else 
            {
                string s;
                if (o is string) 
                    s = o as string;
                else if (o is bool)
                    s = ((bool)o)? "true" : "false";
                else if (o is Double || o is Int16 || o is UInt16 || o is Int32
                    || o is UInt32 || o is Int64 || o is UInt64 || o is Single || o is Decimal)    
                    s = o.ToString();
                else    
                    return null;	
                //Now convert it to text node
                XmlParserContext context = new XmlParserContext(null, null, null, XmlSpace.None);                				    			
                XPathDocument doc = new XPathDocument(
                    new XmlTextReader("<d>"+s+"</d>", XmlNodeType.Element, context));				
                XPathNavigator nav = doc.CreateNavigator();                                         
                if (selectText == null)
                    selectText = nav.Compile("/d/text()");
                return nav.Select(selectText.Clone());
            }
        }
开发者ID:zanyants,项目名称:mvp.xml,代码行数:39,代码来源:ExsltCommon.cs


示例7: ParseIATIXML

        /// <summary>
        /// Implements ParseXML
        /// </summary>
        /// <returns></returns>
        public IXmlResult ParseIATIXML(string url)
        {
            IXmlResult xmlResult;

            var serializer = new XmlSerializer(typeof(XmlResultv1), new XmlRootAttribute("result"));

            // Create an XmlNamespaceManager to resolve namespaces.
            NameTable nameTable = new NameTable();
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(nameTable);
            nsmgr.AddNamespace("iati-extra", "");

            // Create an XmlParserContext.  The XmlParserContext contains all the information
            // required to parse the XML fragment, including the entity information and the
            // XmlNamespaceManager to use for namespace resolution.
            XmlParserContext xmlParserContext = new XmlParserContext(nameTable, nsmgr, null, XmlSpace.None);

            // Create the reader.
            XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
            xmlReaderSettings.NameTable = nameTable;

            using (var Reader = XmlReader.Create(url, xmlReaderSettings, xmlParserContext))
            {
                xmlResult = (XmlResultv1)serializer.Deserialize(Reader);
            }

            return xmlResult;
        }
开发者ID:BD-IATI,项目名称:edi,代码行数:31,代码来源:ParserIATIv1.cs


示例8: ImportAuthors

        public static List<WPAuthor> ImportAuthors(string fileLocation)
        {
            try
            {
                var nsm = new XmlNamespaceManager(new NameTable());
                nsm.AddNamespace("wp", "http://wordpress.org/export/1.2/excerpt/");
                var parseContext = new XmlParserContext(null, nsm, null, XmlSpace.Default);

                using (var reader = XmlReader.Create(fileLocation, null, parseContext))
                {
                    var doc = XDocument.Load(reader);
                    string WordpressNamespace = "http://wordpress.org/export/1.2/";

                    XNamespace wpContent = WordpressNamespace;
                    List<WPAuthor> blogAuthors = new List<WPAuthor>();

                    foreach (XElement element in doc.Descendants("channel"))
                    {
                        foreach (XElement e in element.Descendants(wpContent + "author"))
                        {
                            WPAuthor auth = new WPAuthor(e);
                            blogAuthors.Add(auth);
                        }
                    }

                    return blogAuthors;
                }
            }
            catch (Exception ex)
            {
                Log.Error("Failed to import authors: " + ex.Message, "WP Importer");
                return new List<WPAuthor>();
            }
        }
开发者ID:zmalmquist,项目名称:XBlog,代码行数:34,代码来源:ImportManager.cs


示例9: XmlValidatingReader

 public XmlValidatingReader( Stream xmlFragment, XmlNodeType fragType, XmlParserContext context ) {
     if (xmlFragment == null) {
         throw new ArgumentNullException("xmlFragment");
     }
     impl = new XmlValidatingReaderImpl(xmlFragment, fragType, context);
     impl.OuterReader = this;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:XmlValidatingReader.cs


示例10: Build

 /// <summary>
 /// Constructs an <see cref="IContainerProfile"/>
 /// from a XML fragment.
 /// </summary>
 /// <param name="xmlContents"></param>
 /// <returns></returns>
 public virtual IContainerProfile Build(String xmlContents)
 {
     XmlNamespaceManager nsManager = new XmlNamespaceManager(new NameTable());
     XmlParserContext context = new XmlParserContext(null, nsManager, null, XmlSpace.None);
     XmlReader reader = new XmlTextReader(xmlContents, XmlNodeType.Element, context);
     return Build(reader);
 }
开发者ID:BackupTheBerlios,项目名称:dpml-svn,代码行数:13,代码来源:XmlProfileBuilder.cs


示例11: XmlValidatingReader

	public XmlValidatingReader(String xmlFragment, XmlNodeType fragType,
							   XmlParserContext context)
			{
				reader = new XmlTextReader(xmlFragment, fragType, context);
				entityHandling = EntityHandling.ExpandEntities;
				validationType = ValidationType.Auto;
				reader.Normalization = true;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:8,代码来源:XmlValidatingReader.cs


示例12: Main

        static void Main(string[] args)
        {
            try
            {
                //XML fragment para validar
                string xmlFrag =
                 @"<address  myns:Pais='port' myns:PaisCode='351' xmlns='http://SD/PTAddress.xsd' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'  >" +
                    "<nome>ISEL</nome>" +
                    "<rua>Conselheiro Emidio Navarro</rua>" +
                    "<numero>1</numero>" + "<!-- comentario -->" +
                    "<numero>2</numero>" +
                    "<numero>3</numero>" +
                    "<numero>4</numero>" +
                    "<cidade>Lisboa</cidade>" +
                    "<codigo-postal>1950</codigo-postal>" +
                 "</address>";

                //Set the settings to xml reader and add the schema
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.Schemas.Add("http://SD/PTAddress.xsd", "..\\..\\XMLSchemaPTAddress.xsd");
                settings.ValidationType = ValidationType.Schema;
                settings.ValidationFlags |= XmlSchemaValidationFlags.AllowXmlAttributes;
                settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
                settings.ConformanceLevel = ConformanceLevel.Fragment;
                settings.ValidationEventHandler += new ValidationEventHandler(ShowParserErrors);

                // Create the XmlNamespaceManager.
                XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
                nsmgr.AddNamespace("myns", "http://SD/PTAddress.xsd");

                // Create the XmlParserContext.
                XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);

                XmlReader reader = XmlReader.Create(new StringReader(xmlFrag), settings, context);

                while (reader.Read())
                {
                    //ler toda a string com fragmento xml
                }
                if (!erro) Console.WriteLine("XML fragment VÁLIDO");
            }
            catch (XmlException XmlExp)
            {
                Console.WriteLine(XmlExp.Message);
            }
            catch (XmlSchemaException XmlSchExp)
            {
                Console.WriteLine(XmlSchExp.Message);
            }
            catch (Exception GenExp)
            {
                Console.WriteLine(GenExp.Message);
            }
            finally
            {
                Console.Read();
            }
        }
开发者ID:pepipe,项目名称:ISEL,代码行数:58,代码来源:Program.cs


示例13: EntityResolvingXmlReader

		public EntityResolvingXmlReader (XmlReader source)
		{
			this.source = source;
			IHasXmlParserContext container = source as IHasXmlParserContext;
			if (container != null)
				this.context = container.ParserContext;
			else
				this.context = new XmlParserContext (source.NameTable, new XmlNamespaceManager (source.NameTable), null, XmlSpace.None);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:9,代码来源:EntityResolvingXmlReader.cs


示例14: Parse1

		public void Parse1 ()
		{
			XmlNamespaceManager nsMgr = new MyNS (XmlReader.Create (new StringReader (empty)));
			nsMgr.AddNamespace ("foo", "bar");
			XmlParserContext inputContext = new XmlParserContext (null, nsMgr, null, XmlSpace.None);

			XmlReader xr = XmlReader.Create (new StringReader (xmlstr), new XmlReaderSettings (), inputContext);
			while (xr.Read ()) {}
		}
开发者ID:dfr0,项目名称:moon,代码行数:9,代码来源:XmlNamespaceManagerTest.cs


示例15: XmlValidatingReader

 public XmlValidatingReader(string xmlFragment, XmlNodeType fragType, XmlParserContext context)
 {
     if (xmlFragment == null)
     {
         throw new ArgumentNullException(nameof(xmlFragment));
     }
     _impl = new XmlValidatingReaderImpl(xmlFragment, fragType, context);
     _impl.OuterReader = this;
 }
开发者ID:geoffkizer,项目名称:corefx,代码行数:9,代码来源:XmlValidatingReader.cs


示例16: StringToXmlReader

		/// <summary>
		/// An XML reader is needed to access the XML strings as nodes by the XmlDiff Compare method.
		/// </summary>
		/// <param name="xmlElement">An XML string that is a single element, most usefull when containing other nodes.</param>
		/// <returns>An XML reader for this string.</returns>
		private XmlReader StringToXmlReader(string xmlElement)
		{
			XmlNodeType fragType = XmlNodeType.Element;
			string xmlLang = "";
			System.Xml.XmlSpace xmlSpace = XmlSpace.None;
			XmlNameTable nt = new NameTable();
			System.Xml.XmlNamespaceManager nsMgr = new XmlNamespaceManager(nt);
			XmlParserContext context = new XmlParserContext(nt, nsMgr, xmlLang, xmlSpace);
			return new XmlTextReader(xmlElement, fragType, context);
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:15,代码来源:XmlStringDiff.cs


示例17: ReadAddonXml

        public static XmlDocument ReadAddonXml(CarbonFile file)
        {
            var document = new XmlDocument();

            XmlParserContext context = new XmlParserContext(null, XmlNamespace, string.Empty, XmlSpace.Default);
            XmlReader reader = XmlReader.Create(file.GetPath(), XmlSettings, context);

            document.Load(reader);
            return document;
        }
开发者ID:Craiel,项目名称:CarbonProjects,代码行数:10,代码来源:AddonXmlUtils.cs


示例18: Log4JParserForRemoteMessage

        public Log4JParserForRemoteMessage(
            IRetrieveProcesses processRetriever,
            IHaveExtendedProperties extendedProperties)
        {
            Verify.NotNull(processRetriever, "processRetriever");
            Verify.NotNull(extendedProperties, "extendedProperties");

            this.xmlNamespaceManager = new XmlNamespaceManager(new NameTable());
            this.xmlNamespaceManager.AddNamespace("log4j", "http://logging.apache.org/log4j/");
            this.xmlParserContext = new XmlParserContext(null, this.xmlNamespaceManager, null, XmlSpace.None);
        }
开发者ID:SHSE,项目名称:Harvester,代码行数:11,代码来源:Log4JParserForRemoteMessage.cs


示例19: CreateStrict

        internal static XmlParserContext CreateStrict()
        {
            XmlNameTable nameTable = new NameTable();
            XmlNamespaceManager namespaceManager = new XmlNamespaceManager(nameTable);
            XmlParserContext context = new XmlParserContext(nameTable, namespaceManager, null, XmlSpace.None);

            context.DocTypeName = "html";
            context.PublicId = "-//W3C//DTD XHTML 1.0 Strict//EN";
            context.SystemId = "xhtml1-strict.dtd";
            return context;
        }
开发者ID:bdrhoa,项目名称:redmine-client,代码行数:11,代码来源:CachedXmlResolver.cs


示例20: XmlMessageParser

        protected XmlMessageParser(IRetrieveProcesses processRetriever, String namespacePrefix, String namespaceUri)
        {
            Verify.NotNull(processRetriever, "processRetriever");
            Verify.NotWhitespace(namespacePrefix, "namespacePrefix");
            Verify.NotWhitespace(namespaceUri, "namespaceUri");

            processes = processRetriever;
            xmlNamespaceManager = new XmlNamespaceManager(new NameTable());
            xmlNamespaceManager.AddNamespace(namespacePrefix, namespaceUri);
            xmlParserContext = new XmlParserContext(null, xmlNamespaceManager, null, XmlSpace.None);
        }
开发者ID:jeoffman,项目名称:Harvester,代码行数:11,代码来源:XmlMessageParser.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Xml.XmlQualifiedName类代码示例发布时间:2022-05-26
下一篇:
C# Xml.XmlNodeType类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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