当前位置: 首页>>代码示例>>C#>>正文


C# Xml.XmlNodeType类代码示例

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


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

示例1: CreateNode

        public static XmlNode CreateNode(XmlNodeType type, string name)
        {
            XmlDocument document = new XmlDocument();
            XmlNode node = document.CreateNode(type, name, null);

            return node;
        }
开发者ID:jhenier13,项目名称:StudyCards,代码行数:7,代码来源:XmlUtils.cs

示例2: LoadXml

    public static object LoadXml(string fragment, XmlNodeType xmlNodeType, object target, string filename)
    {
      XamlParser parser = new XamlParser();
      parser._filename = filename;

      return parser.Read(fragment, xmlNodeType, target);
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:7,代码来源:XamlParser.cs

示例3: AssertNode

		void AssertNode (int depth, string localName, XmlNodeType nodeType, string value, string type, XmlDictionaryReader reader, string label)
		{
			Assert.AreEqual (localName, reader.LocalName, label + ".LocalName");
			Assert.AreEqual (nodeType, reader.NodeType, label + ".NodeType");
			Assert.AreEqual (value, reader.Value, label + ".Value");
			Assert.AreEqual (type, reader.GetAttribute ("type"), label + ".GetAttribute('type')");
		}
开发者ID:blinds52,项目名称:mono,代码行数:7,代码来源:JsonReaderTest.cs

示例4: AdvanceNode

        public void AdvanceNode(XmlNodeType xmlNodeType)
        {
            AdvanceNode();

            if (m_xmlReader.NodeType != xmlNodeType)
                throw new Exception("The expected node is " + xmlNodeType);
        }
开发者ID:dekk7,项目名称:xEngine,代码行数:7,代码来源:XmlHelper.cs

示例5: VerifyOwnerOfGivenType

        private static void VerifyOwnerOfGivenType(XmlNodeType nodeType)
        {
            var xmlDocument = new XmlDocument();
            var node = xmlDocument.CreateNode(nodeType, "test", string.Empty);

            Assert.Equal(xmlDocument, node.OwnerDocument);
        }
开发者ID:nandhanurrevanth,项目名称:corefx,代码行数:7,代码来源:OwnerDocumentTests.cs

示例6: ParserNode

 public ParserNode(string name, string value, XmlNodeType nodeType)
 {
     Name = name;
     Value = value;
     NodeType = nodeType;
     Attributes = new Dictionary<string, string>();
 }
开发者ID:benogle,项目名称:html2markup,代码行数:7,代码来源:ParserNode.cs

示例7: OpenXmlMiscNode

        /// <summary>
        /// Initializes a new instance of the OpenXmlMiscNode class using the
        /// supplied XmlNodeType and outer XML values.
        /// </summary>
        /// <param name="nodeType">The XmlNodeType value.</param>
        /// <param name="outerXml">The outer XML of the element.</param>
        public OpenXmlMiscNode(XmlNodeType nodeType, string outerXml)
            : this(nodeType)
        {
            if ( String.IsNullOrEmpty( outerXml ) )
            {
                throw new ArgumentNullException("outerXml");
            }
            
            // check the out XML match the nodeType
            using (StringReader stringReader = new StringReader(outerXml))
            {
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.DtdProcessing = DtdProcessing.Prohibit; // set true explicitly for serucity fix
                using (XmlReader xmlReader = XmlConvertingReaderFactory.Create(stringReader, settings))
                {
                    xmlReader.Read();
                
                    if (xmlReader.NodeType != nodeType)
                    {
                        throw new ArgumentException(ExceptionMessages.InvalidOuterXmlForMiscNode);
                    }

                    xmlReader.Close();
                }
            }

            this.RawOuterXml = outerXml;
        }
开发者ID:eriawan,项目名称:Open-XML-SDK,代码行数:34,代码来源:OpenXmlNonElementNode.cs

示例8: 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

示例9: 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

示例10: ConsumeUntilFirst

 /// <summary>
 /// Consumes nodes from the reader until the first ocurance of the XmlNodeType identified within types.
 /// </summary>
 /// <param name="reader">The reader from which to consume Xml nodes</param>
 /// <param name="types">The XmlNodeType types of interest which will halt consumption</param>
 public static void ConsumeUntilFirst(this XmlReader reader, XmlNodeType[] types)
 {
     while (Array.IndexOf(types, reader.NodeType) < 0)
     {
         reader.Read();
     }
 }
开发者ID:timopk,项目名称:vs-boost-unit-test-adapter,代码行数:12,代码来源:XmlReaderHelper.cs

示例11: IsValidChildType

        internal override bool IsValidChildType(XmlNodeType type)
        {
            switch (type)
            {
                case XmlNodeType.Element:
                case XmlNodeType.Text:
                case XmlNodeType.CDATA:
                case XmlNodeType.EntityReference:
                case XmlNodeType.ProcessingInstruction:
                case XmlNodeType.Comment:
                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                    return true;

                case XmlNodeType.XmlDeclaration:
                {
                    XmlNode firstChild = this.FirstChild;
                    if ((firstChild != null) && (firstChild.NodeType == XmlNodeType.XmlDeclaration))
                    {
                        return false;
                    }
                    return true;
                }
            }
            return false;
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:XmlDocumentFragment.cs

示例12: XmlDiffViewCharData

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="value">innerText for this node</param>
 /// <param name="nodeType">type of node</param>
 internal XmlDiffViewCharData(
     string value,
     XmlNodeType nodeType)
     : base(nodeType)
 {
     this.InnerText = value;
 }
开发者ID:ic014308,项目名称:xml-notepad-for-mono,代码行数:12,代码来源:XmlDiffViewCharData.cs

示例13: Close

 public override void Close()
 {
     this.nav = XmlEmptyNavigator.Singleton;
     this.nodeType = XmlNodeType.None;
     this.state = State.Closed;
     this.depth = 0;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:XPathNavigatorReader.cs

示例14: 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

示例15: TwoTextNodeBase

        private static void TwoTextNodeBase(XmlDocument xmlDocument, InsertType insertType, XmlNodeType nodeType)
        {
            XmlNode parent = xmlDocument.DocumentElement;
            XmlNode refChild = (insertType == InsertType.Prepend) ? parent.FirstChild : parent.LastChild;
            XmlNode newChild = TestHelper.CreateNode(xmlDocument, nodeType);

            string original = parent.InnerXml;
            string expected = (insertType == InsertType.Prepend) ? (newChild.OuterXml + parent.InnerXml)
                : ((insertType == InsertType.Append) ? (parent.InnerXml + newChild.OuterXml)
                : (refChild.PreviousSibling.OuterXml + newChild.OuterXml + refChild.OuterXml));

            // insert new child
            var insertDelegate = TestHelper.CreateInsertBeforeOrAfter(insertType);
            insertDelegate(parent, newChild, refChild);

            // verify
            Assert.Equal(3, parent.ChildNodes.Count);
            Assert.Equal(expected, parent.InnerXml);

            TestHelper.Verify(parent, refChild, newChild);
            TestHelper.VerifySiblings(refChild, newChild, insertType);

            if (insertType == InsertType.Prepend || insertType == InsertType.Append)
                TestHelper.Verify(refChild, newChild, insertType);

            // delete new child
            parent.RemoveChild(newChild);
            Assert.Equal(2, parent.ChildNodes.Count);
            TestHelper.VerifySiblings(parent.FirstChild, parent.LastChild, InsertType.Append);
            Assert.Equal(original, parent.InnerXml);
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:31,代码来源:TwoTextNodeTests.cs


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