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


C# XmlDocument.ReadNode方法代码示例

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


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

示例1: Main

	public static void Main (string [] args)
	{
		if (args.Length == 0) {
			Console.WriteLine ("pass path-to-web.config.");
			return;
		}
		XmlDocument doc = new XmlDocument ();
		doc.Load (args [0]);
		XmlElement el = doc.SelectSingleNode ("/configuration/system.web/httpHandlers") as XmlElement;
		XmlElement old = el.SelectSingleNode ("add[@path='*.svc']") as XmlElement;
		XmlNode up = doc.ReadNode (new XmlTextReader ("fixup-config2.xml"));
		if (old != null)
			el.RemoveChild (old);
		el.InsertAfter (up, null);
		XmlTextWriter w = new XmlTextWriter (args [0], null);
		w.Formatting = Formatting.Indented;
		w.IndentChar = '\t';
		w.Indentation = 1;
		doc.Save (w);
		w.Close ();
	}
开发者ID:nickchal,项目名称:pash,代码行数:21,代码来源:fixup-config2.cs

示例2: Main

	public static void Main (string [] args)
	{
		if (args.Length == 0) {
			Console.WriteLine ("pass path-to-machine.config.");
			return;
		}
		XmlDocument doc = new XmlDocument ();
		doc.Load (args [0]);
		XmlElement el = doc.SelectSingleNode ("/configuration/configSections") as XmlElement;
		XmlElement old = el.SelectSingleNode ("sectionGroup[@name='system.serviceModel']") as XmlElement;
		XmlNode up = doc.ReadNode (new XmlTextReader ("fixup-config.xml"));
		if (old != null)
			el.RemoveChild (old);
		el.InsertAfter (up, null);
		XmlTextWriter w = new XmlTextWriter (args [0], null);
		w.Formatting = Formatting.Indented;
		w.IndentChar = '\t';
		w.Indentation = 1;
		doc.Save (w);
		w.Close ();
	}
开发者ID:nickchal,项目名称:pash,代码行数:21,代码来源:fixup-config.cs

示例3: MoveNext

        public bool MoveNext()
        {
            XmlDocument xmlDoc = new XmlDocument();
            XmlNode testNode;

            try {
                testNode = xmlDoc.ReadNode(reader);
            }
            catch (System.Exception ex) {
                Debug.LogException(ex);
                return false;
            }
            if (testNode != null) {
                currentNode = testNode;
                return true;
            }
            return false;
        }
开发者ID:bluquar,项目名称:Unity-Logger,代码行数:18,代码来源:XMLLogReader.cs

示例4: UploadStream

    /// <summary>
    /// Funtion for client to call for uploading xml file.
    /// takes a file stream as input and ouputs a 
    /// string response in xml format with a message 
    /// element, errors element and succesful element 
    /// on the status of the upload.
    /// </summary>
    /// <param name="stream"></param>
    /// <returns></returns>
    public string UploadStream(System.IO.Stream stream)
    {
        // create vars for validation
        bool bIsValid;
        XmlNode currentRow;
        XmlDocument xmlDoc = new XmlDocument();
        string strErrors = "";

        //create return xmlDoc
        XmlElement parentNode = xmlDoc.CreateElement("upload");;
        CreateReturnXml(xmlDoc, parentNode);

        //this implementation places the uploaded xml file
        //in the bin directory and gives it a unique id filename
        //To Do:should add a meaningful string to filename
        string filePath = HostingEnvironment.ApplicationPhysicalPath + ConfigurationManager.AppSettings["bin"].ToString() + Guid.NewGuid() + ".xml";

        // XmlWriter is not in using block so as to
        // differentiate between xsd validation problem
        // and xml is not well formed problem
        XmlWriter writer = XmlWriter.Create(filePath);
        try
        {
            // creating xmlreader and xmlreaderSetting to validate
            // against and xsd file
            String xsdUri = HostingEnvironment.ApplicationPhysicalPath + ConfigurationManager.AppSettings["XSDPath"].ToString() + "books.xsd";
            XmlReaderSettings xmlSettings = new XmlReaderSettings();
            xmlSettings.ValidationType = ValidationType.Schema;
            xmlSettings.Schemas.Add(null, xsdUri);
            // xml validation handler
            xmlSettings.ValidationEventHandler += delegate(object sender, ValidationEventArgs vargs)
            {
                strErrors += vargs.Message + "\n";
                bIsValid = false;
            };

            // An using block to close xmlreader and xmlwritter
            // in case of an exception
            using (XmlReader reader = XmlReader.Create(stream, xmlSettings))
            {
                //create xmlDocument used to read a node from reader
                XmlDocument doc = new XmlDocument();

                // creating  xmlWriter setting
                XmlWriterSettings xws = new XmlWriterSettings();
                xws.Indent = true;
                writer.Close();
                writer = XmlWriter.Create(filePath, xws);

                // ToFix: find a way to read, validate, and
                // write xml at same time with out using
                // xmlNode (right now loading one xmlNode
                // at a time)

                //loop in the reader until end of xmlreader is reached
                while (reader.Read())
                {
                    // set default of the read to successful
                    bIsValid = true;
                    // read a xmlnode
                    currentRow = doc.ReadNode(reader);
                    // if it is a valid node write to xmlwriter
                    if (bIsValid)
                    {
                        currentRow.WriteTo(writer);
                    }
                    // close xml reader, writer, and the stream
                    // and delete the file and return
                    else
                    {
                        writer.Close();
                        stream.Close();
                        System.IO.File.Delete(filePath);
                        // retrieve the text for return
                        return XsdReturnMessage(xmlDoc, strErrors, parentNode);
                    }
                }
                // xml processed successfully
                // close xml reader, writer, and stream
                writer.Close();
                stream.Close();
                return ValidXml(xmlDoc, filePath, parentNode);
            }
        }
        // if process not sucessful
        // Delete file
        catch (Exception ex)
        {
            ((IDisposable)writer).Dispose();
            stream.Close();
            System.IO.File.Delete(filePath);
//.........这里部分代码省略.........
开发者ID:jlipsun,项目名称:cps,代码行数:101,代码来源:StreamingService.cs


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