當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。