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


C# XmlWriter.WriteWhitespace方法代码示例

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


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

示例1: WriteTo

        public void WriteTo(XmlWriter writer, bool includeWhitespace)
        {
            if (includeWhitespace)
                writer.WriteWhitespace(Environment.NewLine);

            writer.WriteStartElement(ElementName);

            if (AttributesCustom != null && AttributesCustom.Length > 0)
            {
                foreach (XAttributeCustom attribute in AttributesCustom)
                    attribute.WriteTo(writer, includeWhitespace); //Call custom render
            }

            bool hadChildNodes = false;

            if (HasElements)
            {
                foreach (XElementWithAttrib child in Nodes())
                {
                    child.WriteTo(writer, includeWhitespace);
                }

                hadChildNodes = true;
            }
            else
                //This element has just a text value
                writer.WriteValue(Value);

            if (hadChildNodes)
                //Write a new line before the End element
                writer.WriteWhitespace(Environment.NewLine);

            writer.WriteFullEndElement();
        }
开发者ID:ricardoparro,项目名称:pingtree,代码行数:34,代码来源:XElementWithAttrib.cs

示例2: WriteTo

 public override void WriteTo(XmlWriter writer)
 {
     if (Value.Length > 0 && Value.All (c => c == ' ' || c == '\t' || c == '\r' || c == '\n'))
         writer.WriteWhitespace (value);
     else
         writer.WriteString (value);
 }
开发者ID:nicocrm,项目名称:DotNetSDataClient,代码行数:7,代码来源:XText.cs

示例3: createElement

 private void createElement(XmlWriter writer, string whitespace, string name, string value)
 {
     writer.WriteWhitespace(whitespace);
     writer.WriteStartElement(name);
     writer.WriteString(value);
     writer.WriteEndElement();
 }
开发者ID:bobrekjiri,项目名称:StrategyClient,代码行数:7,代码来源:App.xaml.cs

示例4: WriteXml

		public void WriteXml(XmlWriter writer)
		{
			//writer.WriteStartElement(m_name);
			Pairs.Sort((pair1, pair2) => pair1.Key.CompareTo(pair2.Key));
			foreach (var pair in Pairs)
			{
				writer.WriteWhitespace("\n\t\t\t");
				writer.WriteStartElement(pair.Key);
				writer.WriteValue(pair.Value);
				writer.WriteEndElement();
			}
			//writer.WriteEndElement();
		}
开发者ID:remixod,项目名称:netServer,代码行数:13,代码来源:SerializablePairCollection.cs

示例5: WriteTo

 public override void WriteTo(XmlWriter writer)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (base.parent is XDocument)
     {
         writer.WriteWhitespace(this.text);
     }
     else
     {
         writer.WriteString(this.text);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:XText.cs

示例6: WriteNode

        private void WriteNode(XmlWriter xtw, bool defattr)
        {
            int num = (this.NodeType == XmlNodeType.None) ? -1 : this.Depth;
            while (this.Read() && (num < this.Depth))
            {
                switch (this.NodeType)
                {
                    case XmlNodeType.Element:
                        xtw.WriteStartElement(this.Prefix, this.LocalName, this.NamespaceURI);
                        ((XmlTextWriter) xtw).QuoteChar = this.QuoteChar;
                        xtw.WriteAttributes(this, defattr);
                        if (this.IsEmptyElement)
                        {
                            xtw.WriteEndElement();
                        }
                        break;

                    case XmlNodeType.Text:
                        xtw.WriteString(this.Value);
                        break;

                    case XmlNodeType.CDATA:
                        xtw.WriteCData(this.Value);
                        break;

                    case XmlNodeType.EntityReference:
                        xtw.WriteEntityRef(this.Name);
                        break;

                    case XmlNodeType.ProcessingInstruction:
                    case XmlNodeType.XmlDeclaration:
                        xtw.WriteProcessingInstruction(this.Name, this.Value);
                        break;

                    case XmlNodeType.Comment:
                        xtw.WriteComment(this.Value);
                        break;

                    case XmlNodeType.DocumentType:
                        xtw.WriteDocType(this.Name, this.GetAttribute("PUBLIC"), this.GetAttribute("SYSTEM"), this.Value);
                        break;

                    case XmlNodeType.Whitespace:
                    case XmlNodeType.SignificantWhitespace:
                        xtw.WriteWhitespace(this.Value);
                        break;

                    case XmlNodeType.EndElement:
                        xtw.WriteFullEndElement();
                        break;
                }
            }
            if ((num == this.Depth) && (this.NodeType == XmlNodeType.EndElement))
            {
                this.Read();
            }
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:57,代码来源:XmlReader.cs

示例7: EventsToWriter

        /// <summary>
        /// Replay all cached events to an XmlWriter.
        /// </summary>
        public void EventsToWriter(XmlWriter writer) {
            XmlEvent[] page;
            int idxPage, idxEvent;
            byte[] bytes;
            char[] chars;
            XmlRawWriter rawWriter;

            // Special-case single text node at the top-level
            if (this.singleText.Count != 0) {
                writer.WriteString(this.singleText.GetResult());
                return;
            }

            rawWriter = writer as XmlRawWriter;

            // Loop over set of pages
            for (idxPage = 0; idxPage < this.pages.Count; idxPage++) {
                page = this.pages[idxPage];

                // Loop over events in each page
                for (idxEvent = 0; idxEvent < page.Length; idxEvent++) {
                    switch (page[idxEvent].EventType) {
                        case XmlEventType.Unknown:
                            // No more events
                            Debug.Assert(idxPage + 1 == this.pages.Count);
                            return;

                        case XmlEventType.DocType:
                            writer.WriteDocType(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3, (string) page[idxEvent].Object);
                            break;

                        case XmlEventType.StartElem:
                            writer.WriteStartElement(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                            break;

                        case XmlEventType.StartAttr:
                            writer.WriteStartAttribute(page[idxEvent].String1, page[idxEvent].String2, page[idxEvent].String3);
                            break;

                        case XmlEventType.EndAttr:
                            writer.WriteEndAttribute();
                            break;

                        case XmlEventType.CData:
                            writer.WriteCData(page[idxEvent].String1);
                            break;

                        case XmlEventType.Comment:
                            writer.WriteComment(page[idxEvent].String1);
                            break;

                        case XmlEventType.PI:
                            writer.WriteProcessingInstruction(page[idxEvent].String1, page[idxEvent].String2);
                            break;

                        case XmlEventType.Whitespace:
                            writer.WriteWhitespace(page[idxEvent].String1);
                            break;

                        case XmlEventType.String:
                            writer.WriteString(page[idxEvent].String1);
                            break;

                        case XmlEventType.Raw:
                            writer.WriteRaw(page[idxEvent].String1);
                            break;

                        case XmlEventType.EntRef:
                            writer.WriteEntityRef(page[idxEvent].String1);
                            break;

                        case XmlEventType.CharEnt:
                            writer.WriteCharEntity((char) page[idxEvent].Object);
                            break;

                        case XmlEventType.SurrCharEnt:
                            chars = (char[]) page[idxEvent].Object;
                            writer.WriteSurrogateCharEntity(chars[0], chars[1]);
                            break;

                        case XmlEventType.Base64:
                            bytes = (byte[]) page[idxEvent].Object;
                            writer.WriteBase64(bytes, 0, bytes.Length);
                            break;

                        case XmlEventType.BinHex:
                            bytes = (byte[]) page[idxEvent].Object;
                            writer.WriteBinHex(bytes, 0, bytes.Length);
                            break;

                        case XmlEventType.XmlDecl1:
                            if (rawWriter != null)
                                rawWriter.WriteXmlDeclaration((XmlStandalone) page[idxEvent].Object);
                            break;

                        case XmlEventType.XmlDecl2:
                            if (rawWriter != null)
//.........这里部分代码省略.........
开发者ID:uQr,项目名称:referencesource,代码行数:101,代码来源:XmlEventCache.cs

示例8: GenerateQRDACatOne

		private static void GenerateQRDACatOne(List<QualityMeasure> listQMs,DateTime dateStart,DateTime dateEnd,string folderRoot) {
			//create a list of all unique patients who belong to the initial patient population for any of the 9 CQMs
			List<EhrCqmPatient> listAllEhrPats=new List<EhrCqmPatient>();
			//create a dictionary linking a patient to the measures to which they belong
			Dictionary<long,List<QualityMeasure>> dictPatNumListQMs=new Dictionary<long,List<QualityMeasure>>();
			for(int i=0;i<listQMs.Count;i++) {
				for(int j=0;j<listQMs[i].ListEhrPats.Count;j++) {
					if(!dictPatNumListQMs.ContainsKey(listQMs[i].ListEhrPats[j].EhrCqmPat.PatNum)) {
						dictPatNumListQMs.Add(listQMs[i].ListEhrPats[j].EhrCqmPat.PatNum,new List<QualityMeasure>() { listQMs[i] });
						listAllEhrPats.Add(listQMs[i].ListEhrPats[j]);
					}
					else {
						dictPatNumListQMs[listQMs[i].ListEhrPats[j].EhrCqmPat.PatNum].Add(listQMs[i]);
					}
				}
			}
			//listAllPats contains every unique patient who belongs to one of the initial patient population for any of the 9 CQMs
			//dictPatNumListQMs is a dictionary linking a patient to a list of measure for which they are in the initial patient population
			StringBuilder strBuilder=new StringBuilder();
			StringBuilder strBuilderPatDataEntries=new StringBuilder();
			//this dictionary links a PatNum key to the patient's Cat I xml dictionary value
			Dictionary<long,string> dictPatNumXml=new Dictionary<long,string>();
			#region Cateogry I QRDA Documents
			for(int i=0;i<listAllEhrPats.Count;i++) {
				strBuilder=new StringBuilder();
				strBuilderPatDataEntries=new StringBuilder();
				EhrCqmPatient ehrPatCur=listAllEhrPats[i];
				Patient patCur=ehrPatCur.EhrCqmPat;//just to make referencing easier
				long patNumCur=ehrPatCur.EhrCqmPat.PatNum;//just to make referencing easier
				XmlWriterSettings xmlSettings=new XmlWriterSettings();
				xmlSettings.Encoding=Encoding.UTF8;
				xmlSettings.OmitXmlDeclaration=true;
				xmlSettings.Indent=true;
				xmlSettings.IndentChars="   ";
				xmlSettings.ConformanceLevel=ConformanceLevel.Fragment;
				using(_w=XmlWriter.Create(strBuilder,xmlSettings)) {
					//Begin Clinical Document
					_w.WriteRaw("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
					_w.WriteProcessingInstruction("xml-stylesheet","type=\"text/xsl\" href=\"cda.xsl\"");
					_w.WriteWhitespace("\r\n");
					_w.WriteStartElement("ClinicalDocument","urn:hl7-org:v3");
					_w.WriteAttributeString("xmlns","xsi",null,"http://www.w3.org/2001/XMLSchema-instance");
					_w.WriteAttributeString("xsi","schemaLocation",null,"urn:./CDA.xsd");
					_w.WriteAttributeString("xmlns","voc",null,"urn:hl7-org:v3/voc");
					_w.WriteAttributeString("xmlns","sdtc",null,"urn:hl7-org:sdtc");
					#region QRDA I Header
					_w.WriteComment("QRDA Header");
					StartAndEnd("realmCode","code","US");
					StartAndEnd("typeId","root","2.16.840.1.113883.1.3","extension","POCD_HD000040");//template id to assert use of the CDA standard
					_w.WriteComment("US General Header Template");
					TemplateId("2.16.840.1.113883.10.20.22.1.1");
					_w.WriteComment("QRDA Template");
					TemplateId("2.16.840.1.113883.10.20.24.1.1");
					_w.WriteComment("QDM-based QRDA Template");
					TemplateId("2.16.840.1.113883.10.20.24.1.2");
					_w.WriteComment("This is the globally unique identifier for this QRDA document");
					Guid();
					_w.WriteComment("QRDA document type code");
					StartAndEnd("code","code","55182-0","codeSystem",strCodeSystemLoinc,"codeSystemName",strCodeSystemNameLoinc,"displayName","Quality Measure Report");
					_w.WriteElementString("title","QRDA Incidence Report");
					_w.WriteComment("This is the document creation time");
					TimeElement("effectiveTime",DateTime.Now);
					StartAndEnd("confidentialityCode","code","N","codeSystem","2.16.840.1.113883.5.25");//Fixed value.  Confidentiality Code System.  Codes: N=(Normal), R=(Restricted),V=(Very Restricted)
					StartAndEnd("languageCode","code","en-US");
					#region recordTarget
					_w.WriteComment("Reported patient");
					Start("recordTarget");
					#region patientRole
					Start("patientRole");
					string strHICNum=ValidateMedicaidID(patCur.MedicaidID);
					if(strHICNum!="") {
						_w.WriteComment("This is the patient's Medicare HIC (Health Insurance Claim) number");
						StartAndEnd("id","root","2.16.840.1.113883.4.572","extension",strHICNum);
					}
					//_w.WriteComment("The extension is the patient's Open Dental number, the root is the assigning authority");
					//StartAndEnd("id","root",_strOIDInternalPatRoot,"extension",patNumCur.ToString());
					if(patCur.SSN.Trim().Length==9) {
						_w.WriteComment("This is the patient's SSN using the HL7 SSN OID");
						StartAndEnd("id","root","2.16.840.1.113883.4.1","extension",patCur.SSN.Trim());//HL7 SSN OID root with patient's SSN if they have a valid one
					}
					AddressUnitedStates(patCur.Address,patCur.Address2,patCur.City,patCur.State,patCur.Zip,"HP");//Validated
					if(patCur.WirelessPhone.Trim()!="") {//There is at least one phone, due to validation.
						StartAndEnd("telecom","use","MC","value","tel:"+patCur.WirelessPhone.Trim());
						_w.WriteComment("MC is \"mobile contact\" from codeSystem 2.16.840.1.113883.5.1119");
					}
					else if(patCur.HmPhone.Trim()!="") {
						StartAndEnd("telecom","use","HP","value","tel:"+patCur.HmPhone.Trim());
						_w.WriteComment("HP is \"primary home\" from codeSystem 2.16.840.1.113883.5.1119");
					}
					else if(patCur.WkPhone.Trim()!="") {
						StartAndEnd("telecom","use","WP","value","tel:"+patCur.WkPhone.Trim());
						_w.WriteComment("WP is \"work place\" from codeSystem 2.16.840.1.113883.5.1119");
					}
					#region patient
					Start("patient");
					#region name
					Start("name","use","L");
					_w.WriteComment("L is \"Legal\" from codeSystem 2.16.840.1.113883.5.45");
					_w.WriteElementString("given",patCur.FName);//Validated
					if(patCur.MiddleI!="") {
//.........这里部分代码省略.........
开发者ID:romeroyonatan,项目名称:opendental,代码行数:101,代码来源:QualityMeasures.cs

示例9: Connect

        public Task<bool> Connect ()
        {
            lock (writeLock) {
                client = new TcpClient ();

                Log.Debug ("GCM-XMPP: Connecting...");

                //await client.ConnectAsync (Configuration.Host, Configuration.Port).ConfigureAwait (false);
         
                client.Connect (Configuration.Host, Configuration.Port);

                Log.Debug ("GCM-XMPP: Connected.  Creating Secure Channel...");

                sslStream = new SslStream (client.GetStream (), true, (sender, certificate, chain, sslPolicyErrors) => true);

                Log.Debug ("GCM-XMPP: Authenticating Tls...");

                sslStream.AuthenticateAsClient (Configuration.Host, certificates, System.Security.Authentication.SslProtocols.Tls, false);
                stream = sslStream;

                Log.Debug ("GCM-XMPP: Authenticated Tls.");

                var xws = new XmlWriterSettings {
                    Async = true,
                    OmitXmlDeclaration = true,
                    Indent = true,
                    NewLineHandling = NewLineHandling.None,
                    Encoding = new UTF8Encoding (false),
                    CloseOutput = false,               
                };

                xml = XmlWriter.Create (stream, xws);

                Log.Debug ("GCM-XMPP: Writing opening element...");

                //Write initial stream:stream element
                xml.WriteStartElement (STREAM_PREFIX, STREAM_ELEMENT_NAME, STREAM_NAMESPACE);
                xml.WriteAttributeString (string.Empty, "to", string.Empty, "gcm.googleapis.com");
                xml.WriteAttributeString ("version", string.Format ("{0}.{1}", MAJOR_VERSION, MINOR_VERSION));
                xml.WriteAttributeString ("xmlns", JABBER_NAMESPACE);
                xml.WriteWhitespace ("\n");
                xml.Flush ();

                Log.Debug ("GCM-XMPP: Starting Listening...");
            }

            Task.Factory.StartNew (Listen);

            Log.Debug ("GCM-XMPP: Waiting for Authentication...");
            return authCompletion.Task;
        }
开发者ID:CalebKoch,项目名称:PushSharp,代码行数:51,代码来源:GcmXmppConnection.cs

示例10: WriteNode

        private static void WriteNode(XmlWriter writer, XmlNode nodeToWrite)
        {
            if (nodeToWrite.NodeType == XmlNodeType.Comment)
                writer.WriteComment(nodeToWrite.Value);
            else if (nodeToWrite.NodeType == XmlNodeType.Text)
            {
                writer.WriteValue(nodeToWrite.Value);
            }
            else if (nodeToWrite.NodeType == XmlNodeType.Whitespace)
            {
                writer.WriteWhitespace(nodeToWrite.Value);
            }
            else if (nodeToWrite.NodeType == XmlNodeType.SignificantWhitespace)
            {
                Console.WriteLine("SignificantWhitespace ignored");
            }
            else if (nodeToWrite.NodeType == XmlNodeType.Element)
            {
                string nodeName = nodeToWrite.Name;
                if (nodeName == "interface")
                    nodeName = "glade-interface";
                else if (nodeName == "object")
                    nodeName = "widget";

                writer.WriteStartElement(nodeName);
                // Write all attributes
                foreach (XmlAttribute attr in nodeToWrite.Attributes)
                {
                    // Add tab attribute as packing child (Fix for Glade#)
                    if (attr.Name == "type" && attr.Value == "tab")
                    {
                        XmlNode packingNode = nodeToWrite.SelectSingleNode("packing");
                        if (packingNode != null)
                        {
                            XmlElement propNode = nodeToWrite.OwnerDocument.CreateElement("property");
                            XmlAttribute attrType = nodeToWrite.OwnerDocument.CreateAttribute("name");
                            attrType.Value = "type";
                            propNode.Attributes.Append(attrType);
                            propNode.AppendChild(nodeToWrite.OwnerDocument.CreateTextNode("tab"));
                            packingNode.AppendChild(propNode);
                        }
                    }
                    else
                        writer.WriteAttributeString(attr.Name, attr.Value);
                }

                // Move accelerator after signal (Fix for Glade#)
                XmlNode acceleratorNode = nodeToWrite.SelectSingleNode("accelerator");
                if (acceleratorNode != null)
                {
                    XmlNodeList signalNodeList = nodeToWrite.SelectNodes("signal");
                    if (signalNodeList != null && signalNodeList.Count > 0)
                        nodeToWrite.InsertAfter(acceleratorNode, signalNodeList[signalNodeList.Count - 1]);
                }

                // Write all child nodes
                foreach (XmlNode childNode in nodeToWrite.ChildNodes)
                {
                    WriteNode(writer, childNode);
                }
                writer.WriteEndElement();
            }
        }
开发者ID:kashifsoofi,项目名称:bygfoot,代码行数:63,代码来源:GladeHelper.cs

示例11: WriteXml

        /// <summary>
        /// Writes the xml.
        /// </summary>
        /// <param name="writer">The <see cref="XmlWriter"/> to write to</param>
        public void WriteXml(XmlWriter xw)
        {
            xw.WriteStartElement(EventType.ToString());
            xw.WriteAttributeString("Id", Id.ToString());
            if (OutputOptions.HasFlag(TraceOptions.DateTime))
                xw.WriteAttributeString("Time", Time.ToString("yy-MM-dd HH:mm:ss.ffffff "));
            if (OutputOptions.HasFlag(TraceOptions.Timestamp))
                xw.WriteAttributeString("Timestamp", TimeStamp.ToString());
            if (OutputOptions.HasFlag(TraceOptions.ProcessId))
                xw.WriteAttributeString("Process", Process.ToString());
            if (OutputOptions.HasFlag(TraceOptions.ThreadId))
                xw.WriteAttributeString("Thread", Thread);

            xw.WriteAttributeString("Source", Source.Name);
            xw.WriteAttributeString("Method", string.Concat(Frame.GetMethod().ReflectedType.Name, ".", Frame.GetMethod().Name));
            xw.WriteElementString("Message", Message);

            if (OutputOptions.HasFlag(TraceOptions.Callstack))
            {
                xw.WriteStartElement("Callstack");
                foreach (string call in Callstack.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries))
                    xw.WriteElementString("Call", call);		// TODO: split 'call' string into components like file,line,column,type,method,etc/??
                xw.WriteEndElement();
            }
            if (OutputOptions.HasFlag(TraceOptions.LogicalOperationStack) && LogicalOperationStack.Count > 0)
            {
                xw.WriteStartElement("Opstack");
                foreach (object op in LogicalOperationStack)
                    xw.WriteElementString("Op", op.ToString());
                xw.WriteEndElement();
            }
            xw.WriteEndElement();
            xw.WriteWhitespace("\n");
        }
开发者ID:jbowwww,项目名称:JGL,代码行数:38,代码来源:LogMessage.cs

示例12: WriteNodeAsync

 // Writes the content (inner XML) of the current node into the provided XmlWriter.
 private async Task WriteNodeAsync(XmlWriter xtw, bool defattr)
 {
     int d = this.NodeType == XmlNodeType.None ? -1 : this.Depth;
     while (await this.ReadAsync().ConfigureAwait(false) && (d < this.Depth))
     {
         switch (this.NodeType)
         {
             case XmlNodeType.Element:
                 xtw.WriteStartElement(this.Prefix, this.LocalName, this.NamespaceURI);
                 xtw.WriteAttributes(this, defattr);
                 if (this.IsEmptyElement)
                 {
                     xtw.WriteEndElement();
                 }
                 break;
             case XmlNodeType.Text:
                 xtw.WriteString(await this.GetValueAsync().ConfigureAwait(false));
                 break;
             case XmlNodeType.Whitespace:
             case XmlNodeType.SignificantWhitespace:
                 xtw.WriteWhitespace(await this.GetValueAsync().ConfigureAwait(false));
                 break;
             case XmlNodeType.CDATA:
                 xtw.WriteCData(this.Value);
                 break;
             case XmlNodeType.EntityReference:
                 xtw.WriteEntityRef(this.Name);
                 break;
             case XmlNodeType.XmlDeclaration:
             case XmlNodeType.ProcessingInstruction:
                 xtw.WriteProcessingInstruction(this.Name, this.Value);
                 break;
             case XmlNodeType.DocumentType:
                 xtw.WriteDocType(this.Name, this.GetAttribute("PUBLIC"), this.GetAttribute("SYSTEM"), this.Value);
                 break;
             case XmlNodeType.Comment:
                 xtw.WriteComment(this.Value);
                 break;
             case XmlNodeType.EndElement:
                 xtw.WriteFullEndElement();
                 break;
         }
     }
     if (d == this.Depth && this.NodeType == XmlNodeType.EndElement)
     {
         await ReadAsync().ConfigureAwait(false);
     }
 }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:49,代码来源:XmlReaderAsync.cs

示例13: PassNodeThrough

        //copies from example
        private void PassNodeThrough(XmlReader reader, XmlWriter writer)
        {
            switch (reader.NodeType)
            {
                case XmlNodeType.Element:
                    writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
                    writer.WriteAttributes(reader, true);
                    if (reader.IsEmptyElement)
                    {
                        writer.WriteEndElement();
                    }
                    break;

                case XmlNodeType.Text:
                    writer.WriteString(reader.Value);
                    break;

                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                    writer.WriteWhitespace(reader.Value);
                    break;

                case XmlNodeType.CDATA:
                    writer.WriteCData(reader.Value);
                    break;

                case XmlNodeType.EntityReference:
                    writer.WriteEntityRef(reader.Name);
                    break;

                case XmlNodeType.XmlDeclaration:
                case XmlNodeType.ProcessingInstruction:
                    writer.WriteProcessingInstruction(reader.Name, reader.Value);
                    break;

                case XmlNodeType.DocumentType:
                    writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value);
                    break;

                case XmlNodeType.Comment:
                    writer.WriteComment(reader.Value);
                    break;

                case XmlNodeType.EndElement:
                    writer.WriteFullEndElement();
                    break;
            }
        }
开发者ID:ErikCH,项目名称:XMLAssignment,代码行数:49,代码来源:Business.cs

示例14: WriteListOfUris

        public static void WriteListOfUris(XmlWriter writer, Collection<Uri> uris)
        {
            Fx.Assert(writer != null, "The writer must be non null.");
            Fx.Assert(uris != null, "The uris must be non null.");

            if (uris.Count > 0)
            {
                for (int i = 0; i < uris.Count - 1; i++)
                {
                    writer.WriteString(uris[i].GetComponents(UriComponents.SerializationInfoString, UriFormat.UriEscaped));
                    writer.WriteWhitespace(" ");
                }

                writer.WriteString(uris[uris.Count - 1].GetComponents(UriComponents.SerializationInfoString, UriFormat.UriEscaped));
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:16,代码来源:SerializationUtility.cs

示例15: WriteShallowNode

        private static void WriteShallowNode(XmlReader reader, XmlWriter writer)
        {
            switch (reader.NodeType)
            {
                case XmlNodeType.Element:
                    writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
                    writer.WriteAttributes(reader, true);
                    if (reader.IsEmptyElement)
                    {
                        writer.WriteEndElement();
                    }
                    return;

                case XmlNodeType.Text:
                    writer.WriteString(reader.Value);
                    return;

                case XmlNodeType.CDATA:
                    writer.WriteCData(reader.Value);
                    return;

                case XmlNodeType.ProcessingInstruction:
                    writer.WriteProcessingInstruction(reader.Name, reader.Value);
                    return;

                case XmlNodeType.Comment:
                    writer.WriteComment(reader.Value);
                    return;

                case XmlNodeType.DocumentType:
                    writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value);
                    return;

                case XmlNodeType.Whitespace:
                    writer.WriteWhitespace(reader.Value);
                    return;

                case XmlNodeType.SignificantWhitespace:
                    writer.WriteWhitespace(reader.Value);
                    return;

                case XmlNodeType.EndElement:
                    writer.WriteFullEndElement();
                    return;

                case XmlNodeType.XmlDeclaration:
                    writer.WriteProcessingInstruction(reader.Name, reader.Value);
                    return;
            }
            throw new InvalidOperationException("Invalid node");
        }
开发者ID:iansrobinson,项目名称:Restbucks,代码行数:51,代码来源:XmlTransform.cs


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