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


C# XPathDocument.MoveToFirstChild方法代码示例

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


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

示例1: BuildVerifier

 protected BuildVerifier()
 {
     this.m_UnsupportedAssemblies = new Dictionary<string, HashSet<string>>();
     string uri = Path.Combine(Path.Combine(EditorApplication.applicationContentsPath, "Resources"), "BuildVerification.xml");
     XPathNavigator navigator = new XPathDocument(uri).CreateNavigator();
     navigator.MoveToFirstChild();
     XPathNodeIterator iterator = navigator.SelectChildren("assembly", "");
     while (iterator.MoveNext())
     {
         string attribute = iterator.Current.GetAttribute("name", "");
         if ((attribute == null) || (attribute.Length < 1))
         {
             throw new ApplicationException(string.Format("Failed to load {0}, <assembly> name attribute is empty", uri));
         }
         string key = iterator.Current.GetAttribute("platform", "");
         if ((key == null) || (key.Length < 1))
         {
             key = "*";
         }
         if (!this.m_UnsupportedAssemblies.ContainsKey(key))
         {
             this.m_UnsupportedAssemblies.Add(key, new HashSet<string>());
         }
         this.m_UnsupportedAssemblies[key].Add(attribute);
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:26,代码来源:BuildVerifier.cs

示例2: PopulateTree

		public override void PopulateTree (Tree tree)
		{
			XPathNavigator n = new XPathDocument (Path.Combine (basedir, "toc.xml")).CreateNavigator ();
			n.MoveToRoot ();
			n.MoveToFirstChild ();
			PopulateNode (n.SelectChildren ("node", ""), tree.RootNode);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:ecmaspec-provider.cs

示例3: FromXml

 internal static CngKey FromXml(string xml)
 {
     CngKey key;
     using (TextReader reader = new StringReader(xml))
     {
         using (XmlTextReader reader2 = new XmlTextReader(reader))
         {
             BigInteger integer;
             BigInteger integer2;
             XPathNavigator navigator = new XPathDocument(reader2).CreateNavigator();
             if (!navigator.MoveToFirstChild())
             {
                 throw new ArgumentException(System.SR.GetString("Cryptography_MissingDomainParameters"));
             }
             CngAlgorithm algorithm = ReadAlgorithm(navigator);
             if (!navigator.MoveToNext(XPathNodeType.Element))
             {
                 throw new ArgumentException(System.SR.GetString("Cryptography_MissingPublicKey"));
             }
             ReadPublicKey(navigator, out integer, out integer2);
             key = CngKey.Import(NCryptNative.BuildEccPublicBlob(algorithm.Algorithm, integer, integer2), CngKeyBlobFormat.EccPublicBlob);
         }
     }
     return key;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:Rfc4050KeyFormatter.cs

示例4: LinkXmlReader

 public LinkXmlReader()
 {
   foreach (string userBlacklistFile in AssemblyStripper.GetUserBlacklistFiles())
   {
     XPathNavigator navigator = new XPathDocument(userBlacklistFile).CreateNavigator();
     navigator.MoveToFirstChild();
     XPathNodeIterator xpathNodeIterator = navigator.SelectChildren("assembly", string.Empty);
     while (xpathNodeIterator.MoveNext())
       this._assembliesInALinkXmlFile.Add(xpathNodeIterator.Current.GetAttribute("fullname", string.Empty));
   }
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:11,代码来源:LinkXmlReader.cs

示例5: WriteNodeXPathNavigatorAttribute

		public void WriteNodeXPathNavigatorAttribute ()
		{
			string xml = "<!DOCTYPE root [<!ELEMENT root EMPTY> <!ATTLIST root implicit NMTOKEN 'nam'>]><root attr='val' />";
			XPathNavigator nav = new XPathDocument (new StringReader (xml)).CreateNavigator ();
			XmlWriterSettings s = new XmlWriterSettings ();
			s.OmitXmlDeclaration = true;
			StringWriter sw = new StringWriter ();
			XmlWriter w = XmlWriter.Create (sw, s);
			w.WriteStartElement ("hoge");
			nav.MoveToFirstChild ();
			nav.MoveToFirstAttribute ();
			w.WriteNode (nav, false);
			nav.MoveToNextAttribute ();
			w.WriteNode (nav, false);
			w.Close ();
			AssertType.AreEqual ("<hoge />", sw.ToString ());
		}
开发者ID:nobled,项目名称:mono,代码行数:17,代码来源:XmlWriterTests.cs

示例6: ValueAs

		public void ValueAs ()
		{
			string xml = "<root>1</root>";
			XPathNavigator nav = new XPathDocument (XmlReader.Create (new StringReader (xml))).CreateNavigator ();
			nav.MoveToFirstChild ();
			nav.MoveToFirstChild ();
			Assert.AreEqual ("1", nav.ValueAs (typeof (string), null), "#1");
			Assert.AreEqual (1, nav.ValueAs (typeof (int), null), "#2");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:9,代码来源:XPathNavigatorTests.cs

示例7: SignificantWhitespaceConstruction

		public void SignificantWhitespaceConstruction ()
		{
			string xml = @"<root>
        <child xml:space='preserve'>    <!-- -->   </child>
        <child xml:space='preserve'>    </child>
</root>";
			XPathNavigator nav = new XPathDocument (
				new XmlTextReader (xml, XmlNodeType.Document, null),
				XmlSpace.Preserve).CreateNavigator ();
			nav.MoveToFirstChild ();
			nav.MoveToFirstChild ();
			Assert.AreEqual (XPathNodeType.Whitespace, nav.NodeType, "#1");
			nav.MoveToNext ();
			nav.MoveToFirstChild ();
			Assert.AreEqual (XPathNodeType.SignificantWhitespace,
				nav.NodeType, "#2");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:17,代码来源:XPathNavigatorTests.cs

示例8: PushInputDocument

		public void PushInputDocument (string url)
		{
			// todo: detect recursion
			Uri baseUriObj = (Input.BaseURI == String.Empty) ? null : new Uri (Input.BaseURI);
			Uri absUri = res.ResolveUri (baseUriObj, url);
			string absUriString = absUri != null ? absUri.ToString () : String.Empty;
			using (Stream s = (Stream)res.GetEntity (absUri, null, typeof(Stream)))
			{
				if (s == null)
					throw new XsltCompileException ("Can not access URI " + absUri.ToString (), null, Input);
				XmlValidatingReader vr = new XmlValidatingReader (new XmlTextReader (absUriString, s, nsMgr.NameTable));
				vr.ValidationType = ValidationType.None;
				XPathNavigator n = new XPathDocument (vr, XmlSpace.Preserve).CreateNavigator ();
				vr.Close ();
				n.MoveToFirstChild ();
				do {
					if (n.NodeType == XPathNodeType.Element)
						break;
				} while (n.MoveToNext ());
				PushInputDocument (n);
			}
		}
开发者ID:GirlD,项目名称:mono,代码行数:22,代码来源:Compiler.cs

示例9: ExposingSubtreeXmlFragment

		public void ExposingSubtreeXmlFragment()
		{
			string xml = @"
<library>
  <book genre='novel' ISBN='1-861001-57-5'>
     <title>Pride And Prejudice</title>
  </book>
  <book genre='novel' ISBN='1-81920-21-2'>
     <title>Hook</title>
  </book>
</library>";

			XPathNavigator nav = new XPathDocument(new StringReader(xml)).CreateNavigator();

			// <library>
			nav.MoveToFirstChild();
			// <book>
			nav.MoveToFirstChild();

			SubtreeeXPathNavigator sub = new SubtreeeXPathNavigator(nav, true);			
			// Enable fragment reading.
			XPathNavigatorReader reader = new XPathNavigatorReader(sub, true);
			reader.MoveToContent();
			string books = reader.ReadFragmentXml();

			sub.MoveToRoot();
			reader = new XPathNavigatorReader(sub, true);
			reader.MoveToContent();
			string books2 = reader.ReadFragmentXml();

			Assert.AreEqual(books, books2);
			Assert.AreEqual(
				"<book genre=\"novel\" ISBN=\"1-861001-57-5\"><title>Pride And Prejudice</title></book><book genre=\"novel\" ISBN=\"1-81920-21-2\"><title>Hook</title></book>", 
				books);
		}
开发者ID:zanyants,项目名称:mvp.xml,代码行数:35,代码来源:Tests.cs

示例10: XPathDocumentFragmentLoading

		public void XPathDocumentFragmentLoading()
		{
			string xml = "<customer id='1' pp:id='aba' xmlns='urn-kzu' xmlns:pp='urn-pepenamespace'><pp:order /><order id='1'>Chocolates</order></customer>";

			XPathNavigator nav = new XPathDocument(new StringReader(xml)).CreateNavigator();

			// <customer>
			nav.MoveToFirstChild();
			// <pp:order>
			nav.MoveToFirstChild();
			// <order>
			nav.MoveToNext();
			
			XmlReader reader = new XPathNavigatorReader(nav);
			XPathNavigator clone = new XPathDocument(reader).CreateNavigator();
			clone.MoveToFirstChild();
           
			Assert.AreEqual("order", clone.LocalName);
			Assert.AreEqual("urn-kzu", clone.NamespaceURI);
		}
开发者ID:zanyants,项目名称:mvp.xml,代码行数:20,代码来源:Tests.cs

示例11: XPathDocumentLoading

		public void XPathDocumentLoading()
		{
			string xml = "<customer id='1' pp:id='aba' xmlns='urn-kzu' xmlns:pp='urn-pepenamespace'><pp:order /><order id='1'>Chocolates</order></customer>";

			XPathNavigator nav = new XPathDocument(new StringReader(xml)).CreateNavigator();

			XmlReader reader = new XPathNavigatorReader(nav);
			XPathNavigator clone = new XPathDocument(reader).CreateNavigator();
           
			clone.MoveToFirstChild();
			Assert.AreEqual("customer", clone.LocalName);
			Assert.AreEqual("urn-kzu", clone.NamespaceURI);

			clone.MoveToAttribute("id", "urn-pepenamespace");
			Assert.AreEqual("aba", clone.Value);

			clone.MoveToParent();
			clone.MoveToFirstChild();
			Assert.AreEqual("pp:order", clone.Name);
			Assert.IsTrue(clone.IsEmptyElement);			
		}
开发者ID:zanyants,项目名称:mvp.xml,代码行数:21,代码来源:Tests.cs

示例12: XmlDocumentFragmentLoading

		public void XmlDocumentFragmentLoading()
		{
			string xml = "<customer id='1' pp:id='aba' xmlns='urn-kzu' xmlns:pp='urn-pepenamespace'><pp:order /><order id='1'>Chocolates</order></customer>";

			XPathNavigator nav = new XPathDocument(new StringReader(xml)).CreateNavigator();

			// <customer>
			nav.MoveToFirstChild();
			// <pp:order>
			nav.MoveToFirstChild();
			// <order>
			nav.MoveToNext();
			
			XmlReader reader = new XPathNavigatorReader(nav);
			XmlDocument doc = new XmlDocument(nav.NameTable);
			doc.Load( reader );
           
			Assert.AreEqual("order", doc.DocumentElement.LocalName);
			Assert.AreEqual("urn-kzu", doc.DocumentElement.NamespaceURI);
			Assert.AreEqual(1, doc.DocumentElement.Attributes.Count);
		}
开发者ID:zanyants,项目名称:mvp.xml,代码行数:21,代码来源:Tests.cs

示例13: GetData

        /// <summary> 
        /// Fills in the data table with data from a list of HealthRecordItem.
        /// </summary>
        public void GetData(
            HealthRecordAccessor record, IList<HealthRecordItem> items, int startIndex, int count)
        {
            HealthRecordItemDataTableView effectiveView =
                this.ApplyEffectiveView(record.Connection);

            IDictionary<Guid, HealthRecordItemTypeDefinition> typeDefDict =
                ItemTypeManager.GetHealthRecordItemTypeDefinition(_filter.TypeIds,
                    record.Connection);
            HealthRecordItemTypeDefinition sttTypeDef =
                typeDefDict.Count == 1 ? typeDefDict[_filter.TypeIds[0]] : null;

            bool firstRow = true;
            string transformName =
                (effectiveView == HealthRecordItemDataTableView.SingleTypeTable) ? "stt" : "mtt";

            for (int i = startIndex; i < items.Count && i < count; ++i)
            {
                HealthRecordItem item = items[i];

                XPathNavigator itemTransformNav;
                IDictionary<string, XmlDocument> transformedXmlData = item.TransformedXmlData;
                if (transformedXmlData.ContainsKey(transformName))
                {
                    itemTransformNav =
                        transformedXmlData[transformName].CreateNavigator().SelectSingleNode(
                            "//data-xml/row");
                }
                else
                {
                    string transform = (sttTypeDef == null) ?
                        typeDefDict[item.TypeId].TransformItem(transformName, item) :
                        sttTypeDef.TransformItem(transformName, item);

                    itemTransformNav = new XPathDocument(XmlReader.Create(new StringReader(
                        transform))).CreateNavigator();

                    if (!itemTransformNav.MoveToFirstChild())
                    {
                        continue;
                    }
                }

                if (firstRow)
                {
                    SetupColumns(itemTransformNav.Clone());
                    firstRow = false;
                }
                AddRow(itemTransformNav);
            }
        }
开发者ID:marteaga,项目名称:healthvault-azurestorage,代码行数:54,代码来源:HealthRecordItemDataTable.cs

示例14: DeserializeItem

        /// <summary>
        /// Deserializes the response XML into a <see cref="HealthRecordItem"/> or derived type
        /// based on the registered health record item handler.
        /// </summary>
        /// 
        /// <param name="thingReader">
        /// The XML representation of the item.
        /// </param>
        /// 
        /// <returns>
        /// The <see cref="HealthRecordItem"/> or derived class instance representing the data
        /// in the XML.
        /// </returns>
        /// 
        /// <exception cref="System.Reflection.TargetInvocationException">
        /// The constructor of the type being created throws an 
        /// exception. The inner exception is the exception thrown by the
        /// constructor.
        /// </exception>
        /// 
        /// <exception cref="MissingMethodException">
        /// The default constructor of the type being created is not public.
        /// If you registered the type handler, be sure that the type you
        /// registered for the item type class has a public default 
        /// constructor.
        /// </exception>
        /// 
        internal static HealthRecordItem DeserializeItem(XmlReader thingReader)
        {
            HealthRecordItem result = null;

            string thingString = thingReader.ReadOuterXml();

            XmlReaderSettings settings = SDKHelper.XmlReaderSettings;
            settings.IgnoreWhitespace = false;

            XPathNavigator thingNav;
            using (XmlReader reader =
                    XmlReader.Create(new StringReader(thingString), settings))
            {
                thingNav = new XPathDocument(reader, XmlSpace.Preserve).CreateNavigator();
            }

            thingNav.MoveToFirstChild();

            Guid typeId = GetTypeId(thingNav);

            HealthRecordItemTypeHandler handler = null;
            if (typeId == _applicationSpecificId)
            {
                // Handle application specific health item records by checking for handlers
                // for the application ID and subtype tag. If the handler doesn't exist
                // the default handler will be picked up below.

                AppDataKey appDataKey = GetAppDataKey(thingNav);

                if (appDataKey != null)
                {
                    if (_appSpecificHandlers.ContainsKey(appDataKey.AppId))
                    {
                        if (_appSpecificHandlers[appDataKey.AppId].ContainsKey(appDataKey.SubtypeTag))
                        {
                            handler =
                                _appSpecificHandlers[appDataKey.AppId][appDataKey.SubtypeTag];
                        }
                    }
                }
            }

            if (handler == null &&
                TypeHandlers.ContainsKey(typeId))
            {
                handler = TypeHandlers[typeId];
            }

            if (handler != null)
            {
                result = (HealthRecordItem)Activator.CreateInstance(handler.ItemTypeClass);
            }
            else
            {
                result = new HealthRecordItem(typeId);
            }
            result.ParseXml(thingNav, thingString);
            return result;
        }
开发者ID:marteaga,项目名称:healthvault-azurestorage,代码行数:86,代码来源:ItemTypeManager.cs

示例15: SerializeAndReadOutput

        private XPathNavigator SerializeAndReadOutput(ContentItem item)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);

            CreateExporter().Export(item, ExportOptions.Default, sw);

            StringReader sr = new StringReader(sb.ToString());
            XPathNavigator navigator = new XPathDocument(sr).CreateNavigator();
            navigator.MoveToFirstChild();
            return navigator;
        }
开发者ID:FloatLeft,项目名称:n2cms,代码行数:12,代码来源:XmlReaderTests.cs


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