C# (CSharp) System.Xml XmlTextWriter.WriteElementString Examples

Programming Language: C# (CSharp)
Namespace/Package Name: System.Xml
Class/Type: XmlTextWriter
Method/Function: WriteElementString
Examples at hotexamples.com: 49
The System.Xml.XmlTextWriter class is a part of the C# System.Xml package library. It provides a way to write XML documents to a file, stream, or some other output mechanism.

One of the useful methods of the XmlTextWriter class is the WriteElementString(string name, string value) method. This method writes an XML element with the given name and value.

Here are some code examples:

Example 1:
XmlTextWriter writer = new XmlTextWriter("output.xml", null);
writer.WriteStartElement("Person");
writer.WriteElementString("Name", "John");
writer.WriteElementString("Age", "30");
writer.WriteEndElement();
writer.Close();

This code creates an XmlTextWriter object that writes the XML to an output.xml file. It then writes a element with two child elements, and , using WriteElementString() to set their values.

Example 2:
XmlTextWriter writer = new XmlTextWriter(Console.Out);
writer.Formatting = Formatting.Indented;
writer.WriteStartElement("Document");
writer.WriteElementString("Title", "My Document");
writer.WriteElementString("Content", "Some text here.");
writer.WriteEndElement();
writer.Close();
This code creates an XmlTextWriter object that writes the XML to the console output. It sets the Formatting property to Indented to make the output more readable. It then writes a element with two child elements, and <Content>, using WriteElementString(). Both of these examples use the System.Xml.XmlTextWriter class from the C# System.Xml package library to write XML elements with values.</div> <strong>C# (CSharp) System.Xml XmlTextWriter.WriteElementString - 49 examples found</strong>. These are the top rated real world C# (CSharp) examples of <strong>System.Xml.XmlTextWriter.WriteElementString</strong> extracted from open source projects. You can rate examples to help us improve the quality of examples. </div> <div class="hidden-xs"> <div id="ezoic-pub-ad-placeholder-130"> </div> </div> </div> <div id="ezoic-pub-ad-placeholder-105"> <div style="text-align: center; margin-top: 10px"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- after-description --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3697522372581514" data-ad-slot="5330879504" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="visible-xs visible-sm visible-md"> <div class="bs-example thin" style="margin-top: 15px"> <div class="bs-example-title">Frequently Used Methods</div> <div class="fields-controls visible-sm visible-xs visible-md"> <a class="btn btn-default fields-show-btn" data-toggle="collapse" href="#fields-panel-mobile" aria-expanded="false" aria-controls="fields-panel">Show</a> <a class="btn btn-default fields-hide-btn" data-toggle="collapse" href="#fields-panel-mobile" aria-expanded="false" aria-controls="fields-panel">Hide</a> </div> </div> <figure class="highlight panel fields-panel collapse" id="fields-panel-mobile"> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/Close/php-xmltextwriter-close-method-examples.html">Close(30)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteAttributeString/php-xmltextwriter-writeattributestring-method-examples.html">WriteAttributeString(30)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/Flush/php-xmltextwriter-flush-method-examples.html">Flush(30)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteEndAttribute/php-xmltextwriter-writeendattribute-method-examples.html">WriteEndAttribute(30)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteStartElement/php-xmltextwriter-writestartelement-method-examples.html">WriteStartElement(30)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteStartDocument/php-xmltextwriter-writestartdocument-method-examples.html">WriteStartDocument(29)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteBase64/php-xmltextwriter-writebase64-method-examples.html">WriteBase64(26)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html">WriteElementString(19)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteEndElement/php-xmltextwriter-writeendelement-method-examples.html">WriteEndElement(12)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteIfCollectionHasAny/php-xmltextwriter-writeifcollectionhasany-method-examples.html">WriteIfCollectionHasAny(12)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteStringIfValid/php-xmltextwriter-writestringifvalid-method-examples.html">WriteStringIfValid(9)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementStringIfProvided/php-xmltextwriter-writeelementstringifprovided-method-examples.html">WriteElementStringIfProvided(9)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteString/php-xmltextwriter-writestring-method-examples.html">WriteString(9)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteEndDocument/php-xmltextwriter-writeenddocument-method-examples.html">WriteEndDocument(8)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteBinHex/php-xmltextwriter-writebinhex-method-examples.html">WriteBinHex(6)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/LookupPrefix/php-xmltextwriter-lookupprefix-method-examples.html">LookupPrefix(6)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteProcessingInstruction/php-xmltextwriter-writeprocessinginstruction-method-examples.html">WriteProcessingInstruction(6)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementIntIfProvided/php-xmltextwriter-writeelementintifprovided-method-examples.html">WriteElementIntIfProvided(6)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteEntityRef/php-xmltextwriter-writeentityref-method-examples.html">WriteEntityRef(5)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteValue/php-xmltextwriter-writevalue-method-examples.html">WriteValue(4)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementEnum/php-xmltextwriter-writeelementenum-method-examples.html">WriteElementEnum(4)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteComment/php-xmltextwriter-writecomment-method-examples.html">WriteComment(4)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteAttributeStringIf/php-xmltextwriter-writeattributestringif-method-examples.html">WriteAttributeStringIf(3)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteRaw/php-xmltextwriter-writeraw-method-examples.html">WriteRaw(2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteNode/php-xmltextwriter-writenode-method-examples.html">WriteNode(2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteFullEndElement/php-xmltextwriter-writefullendelement-method-examples.html">WriteFullEndElement(2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteWhitespace/php-xmltextwriter-writewhitespace-method-examples.html">WriteWhitespace(2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/field/php-xmltextwriter-field-method-examples.html">field(2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteDocType/php-xmltextwriter-writedoctype-method-examples.html">WriteDocType(2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementListIfAny/php-xmltextwriter-writeelementlistifany-method-examples.html">WriteElementListIfAny(2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementDateTimeIfProvided/php-xmltextwriter-writeelementdatetimeifprovided-method-examples.html">WriteElementDateTimeIfProvided(2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/Dispose/php-xmltextwriter-dispose-method-examples.html">Dispose(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/FlushAsync/php-xmltextwriter-flushasync-method-examples.html">FlushAsync(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/ToString/php-xmltextwriter-tostring-method-examples.html">ToString(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteAttribute/php-xmltextwriter-writeattribute-method-examples.html">WriteAttribute(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteAttributeStringFormat/php-xmltextwriter-writeattributestringformat-method-examples.html">WriteAttributeStringFormat(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteAttributes/php-xmltextwriter-writeattributes-method-examples.html">WriteAttributes(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteCData/php-xmltextwriter-writecdata-method-examples.html">WriteCData(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteStartAttribute/php-xmltextwriter-writestartattribute-method-examples.html">WriteStartAttribute(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteCharEntity/php-xmltextwriter-writecharentity-method-examples.html">WriteCharEntity(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteQualifiedName/php-xmltextwriter-writequalifiedname-method-examples.html">WriteQualifiedName(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteChars/php-xmltextwriter-writechars-method-examples.html">WriteChars(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteOptionalElement/php-xmltextwriter-writeoptionalelement-method-examples.html">WriteOptionalElement(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteName/php-xmltextwriter-writename-method-examples.html">WriteName(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementRange/php-xmltextwriter-writeelementrange-method-examples.html">WriteElementRange(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteMandatoryElement/php-xmltextwriter-writemandatoryelement-method-examples.html">WriteMandatoryElement(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementAndValue/php-xmltextwriter-writeelementandvalue-method-examples.html">WriteElementAndValue(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementBool/php-xmltextwriter-writeelementbool-method-examples.html">WriteElementBool(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementChannelSettings/php-xmltextwriter-writeelementchannelsettings-method-examples.html">WriteElementChannelSettings(1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementDateTimeIfFuture/php-xmltextwriter-writeelementdatetimeiffuture-method-examples.html">WriteElementDateTimeIfFuture(1)</a> </div> </figure> </div> </div> <div class="page-content-container"> <div class="sidebar hidden-xs hidden-sm hidden-md" style="width:300px"> <div id="ezoic-pub-ad-placeholder-101"> <div style="text-align: center; margin-top: 10px"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- left-sidebar-1 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3697522372581514" data-ad-slot="7161345231" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="bs-example thin"> <div class="bs-example-title"> Frequently Used Methods </div> </div> <figure class="highlight panel fields-panel " id="fields-panel"> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/Close/php-xmltextwriter-close-method-examples.html">Close (30)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteAttributeString/php-xmltextwriter-writeattributestring-method-examples.html">WriteAttributeString (30)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/Flush/php-xmltextwriter-flush-method-examples.html">Flush (30)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteEndAttribute/php-xmltextwriter-writeendattribute-method-examples.html">WriteEndAttribute (30)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteStartElement/php-xmltextwriter-writestartelement-method-examples.html">WriteStartElement (30)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteStartDocument/php-xmltextwriter-writestartdocument-method-examples.html">WriteStartDocument (29)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteBase64/php-xmltextwriter-writebase64-method-examples.html">WriteBase64 (26)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html">WriteElementString (19)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteEndElement/php-xmltextwriter-writeendelement-method-examples.html">WriteEndElement (12)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteIfCollectionHasAny/php-xmltextwriter-writeifcollectionhasany-method-examples.html">WriteIfCollectionHasAny (12)</a> </div> </figure> <div id="ezoic-pub-ad-placeholder-102"> <div style="text-align: center; margin-bottom: 10px"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- left-sidebar-2 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3697522372581514" data-ad-slot="7075206013" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="bs-example thin"> <div class="bs-example-title"> Frequently Used Methods </div> </div> <figure class="highlight panel fields-panel " id="fields-panel"> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteStringIfValid/php-xmltextwriter-writestringifvalid-method-examples.html">WriteStringIfValid (9)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementStringIfProvided/php-xmltextwriter-writeelementstringifprovided-method-examples.html">WriteElementStringIfProvided (9)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteString/php-xmltextwriter-writestring-method-examples.html">WriteString (9)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteEndDocument/php-xmltextwriter-writeenddocument-method-examples.html">WriteEndDocument (8)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteBinHex/php-xmltextwriter-writebinhex-method-examples.html">WriteBinHex (6)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/LookupPrefix/php-xmltextwriter-lookupprefix-method-examples.html">LookupPrefix (6)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteProcessingInstruction/php-xmltextwriter-writeprocessinginstruction-method-examples.html">WriteProcessingInstruction (6)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementIntIfProvided/php-xmltextwriter-writeelementintifprovided-method-examples.html">WriteElementIntIfProvided (6)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteEntityRef/php-xmltextwriter-writeentityref-method-examples.html">WriteEntityRef (5)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteValue/php-xmltextwriter-writevalue-method-examples.html">WriteValue (4)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementEnum/php-xmltextwriter-writeelementenum-method-examples.html">WriteElementEnum (4)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteComment/php-xmltextwriter-writecomment-method-examples.html">WriteComment (4)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteAttributeStringIf/php-xmltextwriter-writeattributestringif-method-examples.html">WriteAttributeStringIf (3)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteRaw/php-xmltextwriter-writeraw-method-examples.html">WriteRaw (2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteNode/php-xmltextwriter-writenode-method-examples.html">WriteNode (2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteFullEndElement/php-xmltextwriter-writefullendelement-method-examples.html">WriteFullEndElement (2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteWhitespace/php-xmltextwriter-writewhitespace-method-examples.html">WriteWhitespace (2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/field/php-xmltextwriter-field-method-examples.html">field (2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteDocType/php-xmltextwriter-writedoctype-method-examples.html">WriteDocType (2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementListIfAny/php-xmltextwriter-writeelementlistifany-method-examples.html">WriteElementListIfAny (2)</a> </div> </figure> <div id="ezoic-pub-ad-placeholder-117"> </div> <div class="bs-example thin"> <div class="bs-example-title"> Frequently Used Methods </div> </div> <figure class="highlight panel fields-panel " id="fields-panel"> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementEnum/php-xmltextwriter-writeelementenum-method-examples.html">WriteElementEnum (4)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteComment/php-xmltextwriter-writecomment-method-examples.html">WriteComment (4)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteAttributeStringIf/php-xmltextwriter-writeattributestringif-method-examples.html">WriteAttributeStringIf (3)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteRaw/php-xmltextwriter-writeraw-method-examples.html">WriteRaw (2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteNode/php-xmltextwriter-writenode-method-examples.html">WriteNode (2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteFullEndElement/php-xmltextwriter-writefullendelement-method-examples.html">WriteFullEndElement (2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteWhitespace/php-xmltextwriter-writewhitespace-method-examples.html">WriteWhitespace (2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/field/php-xmltextwriter-field-method-examples.html">field (2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteDocType/php-xmltextwriter-writedoctype-method-examples.html">WriteDocType (2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementListIfAny/php-xmltextwriter-writeelementlistifany-method-examples.html">WriteElementListIfAny (2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementDateTimeIfProvided/php-xmltextwriter-writeelementdatetimeifprovided-method-examples.html">WriteElementDateTimeIfProvided (2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/Dispose/php-xmltextwriter-dispose-method-examples.html">Dispose (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/FlushAsync/php-xmltextwriter-flushasync-method-examples.html">FlushAsync (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/ToString/php-xmltextwriter-tostring-method-examples.html">ToString (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteAttribute/php-xmltextwriter-writeattribute-method-examples.html">WriteAttribute (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteAttributeStringFormat/php-xmltextwriter-writeattributestringformat-method-examples.html">WriteAttributeStringFormat (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteAttributes/php-xmltextwriter-writeattributes-method-examples.html">WriteAttributes (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteCData/php-xmltextwriter-writecdata-method-examples.html">WriteCData (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteStartAttribute/php-xmltextwriter-writestartattribute-method-examples.html">WriteStartAttribute (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteCharEntity/php-xmltextwriter-writecharentity-method-examples.html">WriteCharEntity (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteQualifiedName/php-xmltextwriter-writequalifiedname-method-examples.html">WriteQualifiedName (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteChars/php-xmltextwriter-writechars-method-examples.html">WriteChars (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteOptionalElement/php-xmltextwriter-writeoptionalelement-method-examples.html">WriteOptionalElement (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteName/php-xmltextwriter-writename-method-examples.html">WriteName (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementRange/php-xmltextwriter-writeelementrange-method-examples.html">WriteElementRange (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteMandatoryElement/php-xmltextwriter-writemandatoryelement-method-examples.html">WriteMandatoryElement (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementAndValue/php-xmltextwriter-writeelementandvalue-method-examples.html">WriteElementAndValue (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementBool/php-xmltextwriter-writeelementbool-method-examples.html">WriteElementBool (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementChannelSettings/php-xmltextwriter-writeelementchannelsettings-method-examples.html">WriteElementChannelSettings (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementDateTimeIfFuture/php-xmltextwriter-writeelementdatetimeiffuture-method-examples.html">WriteElementDateTimeIfFuture (1)</a> </div> </figure> <div id="ezoic-pub-ad-placeholder-116"> </div> <div class="hidden-xs hidden-sm"> <div class="bs-example thin"> <div class="bs-example-title">Related in langs</div> </div> <figure class="highlight panel"> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://hotexamples.com/examples/-/-/save_users/php-save_users-function-examples.html">save_users (PHP)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://hotexamples.com/examples/consolidation.annotatedcommand/AnnotatedCommandFactory/-/php-annotatedcommandfactory-class-examples.html">AnnotatedCommandFactory (PHP)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://cpp.hotexamples.com/examples/-/-/put_long_host/cpp-put_long_host-function-examples.html">put_long_host (C++)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://cpp.hotexamples.com/examples/-/-/pcan_fifo_reset/cpp-pcan_fifo_reset-function-examples.html">pcan_fifo_reset (C++)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://golang.hotexamples.com/examples/github.com.google.certificate-transparency.go.client/LogClient/-/golang-logclient-class-examples.html">LogClient (Go)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://golang.hotexamples.com/examples/github.com.roasbeef.btcd.btcjson/-/MethodUsageFlags/golang-methodusageflags-function-examples.html">MethodUsageFlags (Go)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://java.hotexamples.com/examples/org.nuxeo.ecm.core.api/Blobs/-/java-blobs-class-examples.html">Blobs (Java)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://java.hotexamples.com/examples/com.symbol.wp.core.util/ReqUtils/-/java-requtils-class-examples.html">ReqUtils (Java)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://python.hotexamples.com/examples/events.backend/-/events/python-events-function-examples.html">events (Python)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://python.hotexamples.com/examples/jaikucommon.api/-/oauth_authorize_request_token/python-oauth_authorize_request_token-function-examples.html">oauth_authorize_request_token (Python)</a> </div> </figure> </div> <div class="bs-example thin"> <div class="bs-example-title"> Frequently Used Methods </div> </div> <figure class="highlight panel fields-panel fields-panel-last" id="fields-panel"> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementDateTimeIfProvided/php-xmltextwriter-writeelementdatetimeifprovided-method-examples.html">WriteElementDateTimeIfProvided (2)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/Dispose/php-xmltextwriter-dispose-method-examples.html">Dispose (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/FlushAsync/php-xmltextwriter-flushasync-method-examples.html">FlushAsync (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/ToString/php-xmltextwriter-tostring-method-examples.html">ToString (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteAttribute/php-xmltextwriter-writeattribute-method-examples.html">WriteAttribute (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteAttributeStringFormat/php-xmltextwriter-writeattributestringformat-method-examples.html">WriteAttributeStringFormat (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteAttributes/php-xmltextwriter-writeattributes-method-examples.html">WriteAttributes (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteCData/php-xmltextwriter-writecdata-method-examples.html">WriteCData (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteStartAttribute/php-xmltextwriter-writestartattribute-method-examples.html">WriteStartAttribute (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteCharEntity/php-xmltextwriter-writecharentity-method-examples.html">WriteCharEntity (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteQualifiedName/php-xmltextwriter-writequalifiedname-method-examples.html">WriteQualifiedName (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteChars/php-xmltextwriter-writechars-method-examples.html">WriteChars (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteOptionalElement/php-xmltextwriter-writeoptionalelement-method-examples.html">WriteOptionalElement (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteName/php-xmltextwriter-writename-method-examples.html">WriteName (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementRange/php-xmltextwriter-writeelementrange-method-examples.html">WriteElementRange (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteMandatoryElement/php-xmltextwriter-writemandatoryelement-method-examples.html">WriteMandatoryElement (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementAndValue/php-xmltextwriter-writeelementandvalue-method-examples.html">WriteElementAndValue (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementBool/php-xmltextwriter-writeelementbool-method-examples.html">WriteElementBool (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementChannelSettings/php-xmltextwriter-writeelementchannelsettings-method-examples.html">WriteElementChannelSettings (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementDateTimeIfFuture/php-xmltextwriter-writeelementdatetimeiffuture-method-examples.html">WriteElementDateTimeIfFuture (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementIfNotEmpty/php-xmltextwriter-writeelementifnotempty-method-examples.html">WriteElementIfNotEmpty (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementU32/php-xmltextwriter-writeelementu32-method-examples.html">WriteElementU32 (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementList/php-xmltextwriter-writeelementlist-method-examples.html">WriteElementList (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementStringAsNillable/php-xmltextwriter-writeelementstringasnillable-method-examples.html">WriteElementStringAsNillable (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementS32/php-xmltextwriter-writeelements32-method-examples.html">WriteElementS32 (1)</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementMotorLimits/php-xmltextwriter-writeelementmotorlimits-method-examples.html">WriteElementMotorLimits (1)</a> </div> </figure> <div class="hidden-xs hidden-sm"> <div class="bs-example thin"> <div class="bs-example-title">Related</div> </div> <figure class="highlight panel"> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/-/ErrorFix/-/php-errorfix-class-examples.html">ErrorFix</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/-/classDiagnostico/-/php-classdiagnostico-class-examples.html">classDiagnostico</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/-/CompanyOrderCreateViewModel/-/php-companyordercreateviewmodel-class-examples.html">CompanyOrderCreateViewModel</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/-/SkillOffered/-/php-skilloffered-class-examples.html">SkillOffered</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/Spherus.Notifications.Mail.SparkPost/TransmissionContent/-/php-transmissioncontent-class-examples.html">TransmissionContent</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/-/XOfficeCommonSettingsHandler/-/php-xofficecommonsettingshandler-class-examples.html">XOfficeCommonSettingsHandler</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/PSC2013.ES.Library.Snapshot/TickSnapshot/-/php-ticksnapshot-class-examples.html">TickSnapshot</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/TradingTechnologies.TTAPI/OrderAddedEventArgs/-/php-orderaddedeventargs-class-examples.html">OrderAddedEventArgs</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/-/SmoothedZSmoothening/-/php-smoothedzsmoothening-class-examples.html">SmoothedZSmoothening</a> </div> <div style="overflow: hidden;text-overflow: ellipsis;"> <a href="https://csharp.hotexamples.com/examples/-/DALogIn/-/php-dalogin-class-examples.html">DALogIn</a> </div> </figure> </div> </div> <div class="main-content"> <div class="addthis_inline_share_toolbox_o6yp"></div> <div style="margin-top: 10px"> <div class="row" style="margin-bottom: 15px"> <div class="col-md-12"> <a class="btn btn-default" href="https://csharpdoc.hotexamples.com/class/System.Xml/XmlTextWriter"> XmlTextWriter Class Documentation </a> </div> </div> </div> <div id="ezoic-pub-ad-placeholder-106"> </div> <div class="example-item" id="0xf2a646f97b9d7f9f7c34f99c0cbfe8829f26f63da98eedea9c1eb0aef1cd6535-13,,41,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #1</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_1" data-hash="0xf2a646f97b9d7f9f7c34f99c0cbfe8829f26f63da98eedea9c1eb0aef1cd6535" data-area="13,,41,"> <div class="rating-amount">1</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '1')" class="rating-up btn btn-success" data-id="rating_1"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'1')" class="rating-down btn btn-danger" data-id="rating_1"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xf2a646f97b9d7f9f7c34f99c0cbfe8829f26f63da98eedea9c1eb0aef1cd6535-13,,41,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xf2a646f97b9d7f9f7c34f99c0cbfe8829f26f63da98eedea9c1eb0aef1cd6535&fullName=02.+Processing+XML+in+.NET%2FHomework%2FHomeworkXML.NET%2FProgram.cs&project=DimitarDKirov%2FData-Bases')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FDimitarDKirov%2FData-Bases%2Fblob%2Fmaster%2F02.+Processing+XML+in+.NET%2FHomework%2FHomeworkXML.NET%2FProgram.cs">Program.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FDimitarDKirov%2FData-Bases">DimitarDKirov/Data-Bases</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="1"> <pre class="line-numbers language-csharp" data-end="41" data-start="14" data-highlight="32,34,36"> static void Main(string[] args) { string textFile = "../../PersonData.txt"; string xmlFile = "../../Person.xml"; using (XmlTextWriter xmlWriter = new XmlTextWriter(xmlFile, Encoding.GetEncoding("utf-8"))) { xmlWriter.Formatting = Formatting.Indented; xmlWriter.IndentChar = '\t'; xmlWriter.Indentation = 1; xmlWriter.WriteStartDocument(); xmlWriter.WriteStartElement("person"); xmlWriter.WriteAttributeString("id", "1"); using (StreamReader fileReader = new StreamReader(textFile)) { string name = fileReader.ReadLine(); xmlWriter.WriteElementString("name", name); string address = fileReader.ReadLine(); xmlWriter.WriteElementString("address", address); string phone = fileReader.ReadLine(); xmlWriter.WriteElementString("phone", phone); } xmlWriter.WriteEndElement(); xmlWriter.WriteEndDocument(); } }</pre> </div> </figure> </div> <div id="ezoic-pub-ad-placeholder-107"> <div style="text-align: center;margin-bottom: 10px"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- after-example-1 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3697522372581514" data-ad-slot="4981531786" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="example-item" id="0xb2f001055df80d6c4129381df33c5fd82fd4011adb90cdb0d2fe78c68a59efc4-13,,45,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #2</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_2" data-hash="0xb2f001055df80d6c4129381df33c5fd82fd4011adb90cdb0d2fe78c68a59efc4" data-area="13,,45,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '2')" class="rating-up btn btn-success" data-id="rating_2"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'2')" class="rating-down btn btn-danger" data-id="rating_2"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xb2f001055df80d6c4129381df33c5fd82fd4011adb90cdb0d2fe78c68a59efc4-13,,45,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xb2f001055df80d6c4129381df33c5fd82fd4011adb90cdb0d2fe78c68a59efc4&fullName=AviBlog%2FAviBlog.Core%2FPingWebRequestHelper.cs&project=avington%2Faviblog')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Favington%2Faviblog%2Fblob%2Fmaster%2FAviBlog%2FAviBlog.Core%2FPingWebRequestHelper.cs">PingWebRequestHelper.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Favington%2Faviblog">avington/aviblog</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="2"> <pre class="line-numbers language-csharp" data-end="45" data-start="14" data-highlight="28,31,34"> public void Send(string serviceUrl, string postUrl, string blogName) { try { var request = (HttpWebRequest)WebRequest.Create(serviceUrl); request.Method = "POST"; request.ContentType = "text/xml"; request.Timeout = 3000; request.Credentials = CredentialCache.DefaultNetworkCredentials; var stream = request.GetRequestStream(); using (var writer = new XmlTextWriter(stream, Encoding.ASCII)) { writer.WriteStartDocument(); writer.WriteStartElement("methodCall"); writer.WriteElementString("methodName", "weblogUpdates.ping"); writer.WriteStartElement("params"); writer.WriteStartElement("param"); writer.WriteElementString("value", blogName); writer.WriteEndElement(); writer.WriteStartElement("param"); writer.WriteElementString("value", postUrl); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndElement(); } request.GetResponse(); } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(new NotSupportedException()); } }</pre> </div> </figure> </div> <div id="ezoic-pub-ad-placeholder-108"> <div style="text-align: center;"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- after-example-2 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3697522372581514" data-ad-slot="7155150962" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="example-item" id="0xd0d16b1479982524f80ab61590ed14c5d1d64b7a8b39ad847cfc09e6de8354eb-42,,67,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #3</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_3" data-hash="0xd0d16b1479982524f80ab61590ed14c5d1d64b7a8b39ad847cfc09e6de8354eb" data-area="42,,67,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '3')" class="rating-up btn btn-success" data-id="rating_3"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'3')" class="rating-down btn btn-danger" data-id="rating_3"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xd0d16b1479982524f80ab61590ed14c5d1d64b7a8b39ad847cfc09e6de8354eb-42,,67,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xd0d16b1479982524f80ab61590ed14c5d1d64b7a8b39ad847cfc09e6de8354eb&fullName=OpenSim%2FFramework%2FSerialization%2FUserProfileSerializer.cs&project=AlphaStaxLLC%2Ftaiga')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FAlphaStaxLLC%2Ftaiga%2Fblob%2Fmaster%2FOpenSim%2FFramework%2FSerialization%2FUserProfileSerializer.cs">UserProfileSerializer.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FAlphaStaxLLC%2Ftaiga">AlphaStaxLLC/taiga</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="3"> <pre class="line-numbers language-csharp" data-end="67" data-start="43" data-highlight="54,55,56"> public static string Serialize(UserProfileData profile) { StringWriter sw = new StringWriter(); XmlTextWriter xtw = new XmlTextWriter(sw); xtw.Formatting = Formatting.Indented; xtw.WriteStartDocument(); xtw.WriteStartElement("user_profile"); xtw.WriteAttributeString("major_version", MAJOR_VERSION.ToString()); xtw.WriteAttributeString("minor_version", MINOR_VERSION.ToString()); xtw.WriteElementString("name", profile.Name); xtw.WriteElementString("id", profile.ID.ToString()); xtw.WriteElementString("about", profile.AboutText); // Not sure if we're storing this yet, need to take a look // xtw.WriteElementString("Url", profile.Url); // or, indeed, interests xtw.WriteEndElement(); xtw.Close(); sw.Close(); return sw.ToString(); }</pre> </div> </figure> </div> <div id="ezoic-pub-ad-placeholder-109"> <div style="text-align: center;"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- after-example-3 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3697522372581514" data-ad-slot="8699811701" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="example-item" id="0xc2efa05489d845ee35f3c290ba41d6e93a51b5a44b82e9ae0ecd93620f66724b-52,,77,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #4</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_4" data-hash="0xc2efa05489d845ee35f3c290ba41d6e93a51b5a44b82e9ae0ecd93620f66724b" data-area="52,,77,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '4')" class="rating-up btn btn-success" data-id="rating_4"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'4')" class="rating-down btn btn-danger" data-id="rating_4"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xc2efa05489d845ee35f3c290ba41d6e93a51b5a44b82e9ae0ecd93620f66724b-52,,77,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xc2efa05489d845ee35f3c290ba41d6e93a51b5a44b82e9ae0ecd93620f66724b&fullName=06.Database%2F17.XMLProcessingIn.NET%2FXMLProcessing%2FCreateXmlFromTextFile.cs&project=NikolayKostadinov%2FHomeworks')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FNikolayKostadinov%2FHomeworks%2Fblob%2Fmaster%2F06.Database%2F17.XMLProcessingIn.NET%2FXMLProcessing%2FCreateXmlFromTextFile.cs">CreateXmlFromTextFile.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FNikolayKostadinov%2FHomeworks">NikolayKostadinov/Homeworks</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="4"> <pre class="line-numbers language-csharp" data-end="77" data-start="53" data-highlight="70,71,72"> private static void SaveManToXml(IList<Man> people) { string fileName = "../../peoples.xml"; using (XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.GetEncoding("windows-1251"))) { writer.Formatting = Formatting.Indented; writer.IndentChar = '\t'; writer.Indentation = 1; writer.WriteStartDocument(); writer.WriteStartElement("people"); foreach (var man in people) { writer.WriteStartElement("person"); writer.WriteElementString("name", man.Name); writer.WriteElementString("address", man.Address); writer.WriteElementString("phone", man.Phone); writer.WriteEndElement(); } writer.WriteEndElement(); } }</pre> </div> </figure> </div> <div id="ezoic-pub-ad-placeholder-110"> </div> <div class="example-item" id="0xc7a7c6e78f7d6789b5b31f8b3100af6a850c740ca2e7549f38b4361ad3989b03-37,,61,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #5</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_5" data-hash="0xc7a7c6e78f7d6789b5b31f8b3100af6a850c740ca2e7549f38b4361ad3989b03" data-area="37,,61,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '5')" class="rating-up btn btn-success" data-id="rating_5"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'5')" class="rating-down btn btn-danger" data-id="rating_5"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xc7a7c6e78f7d6789b5b31f8b3100af6a850c740ca2e7549f38b4361ad3989b03-37,,61,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xc7a7c6e78f7d6789b5b31f8b3100af6a850c740ca2e7549f38b4361ad3989b03&fullName=TTVProxy%2FUpnpServer.cs&project=northspb%2Fp2pproxy')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fnorthspb%2Fp2pproxy%2Fblob%2Fmaster%2FTTVProxy%2FUpnpServer.cs">UpnpServer.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fnorthspb%2Fp2pproxy">northspb/p2pproxy</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="5"> <pre class="line-numbers language-csharp" data-end="61" data-start="38" data-highlight="49,50"> private void GenerateDescription(string host = null) { MemoryStream memStream = new MemoryStream(); using (XmlTextWriter descWriter = new XmlTextWriter(memStream, new UTF8Encoding(false))) { descWriter.Formatting = Formatting.Indented; descWriter.WriteRaw("<?xml version=\"1.0\"?>"); descWriter.WriteStartElement("root", "urn:schemas-upnp-org:device-1-0"); descWriter.WriteStartElement("specVersion"); descWriter.WriteElementString("major", "1"); descWriter.WriteElementString("minor", "0"); descWriter.WriteEndElement(); descWriter.WriteStartElement("device"); rootDevice.WriteDescription(descWriter, host); descWriter.WriteEndElement(); descWriter.WriteEndElement(); descWriter.Flush(); descArray = memStream.ToArray(); } }</pre> </div> </figure> </div> <div id="ezoic-pub-ad-placeholder-111"> </div> <div class="example-item" id="0xdc7fd84fa8301db0d643207c153ce0b38215f51163908fdf47f6819e4d653468-466,,499,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #6</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_6" data-hash="0xdc7fd84fa8301db0d643207c153ce0b38215f51163908fdf47f6819e4d653468" data-area="466,,499,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '6')" class="rating-up btn btn-success" data-id="rating_6"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'6')" class="rating-down btn btn-danger" data-id="rating_6"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xdc7fd84fa8301db0d643207c153ce0b38215f51163908fdf47f6819e4d653468-466,,499,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xdc7fd84fa8301db0d643207c153ce0b38215f51163908fdf47f6819e4d653468&fullName=ardupilotone-master%2FTools%2FMavlinkLog.cs&project=reiha12%2Fardupilotone')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Freiha12%2Fardupilotone%2Fblob%2Fmaster%2Fardupilotone-master%2FTools%2FMavlinkLog.cs">MavlinkLog.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Freiha12%2Fardupilotone">reiha12/ardupilotone</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="6"> <pre class="line-numbers language-csharp" data-end="499" data-start="467" data-highlight="483,484,485,487,488"> private void writeGPX(string filename) { System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(filename) + ".gpx", Encoding.ASCII); xw.WriteStartElement("gpx"); xw.WriteStartElement("trk"); xw.WriteStartElement("trkseg"); foreach (CurrentState cs in flightdata) { xw.WriteStartElement("trkpt"); xw.WriteAttributeString("lat", cs.lat.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteAttributeString("lon", cs.lng.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("ele", cs.alt.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("time", cs.datetime.ToString("yyyy-MM-ddTHH:mm:sszzzzzz")); xw.WriteElementString("course", (cs.yaw).ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("roll", cs.roll.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("pitch", cs.pitch.ToString(new System.Globalization.CultureInfo("en-US"))); //xw.WriteElementString("speed", mod.model.Orientation.); //xw.WriteElementString("fix", cs.altitude); xw.WriteEndElement(); } xw.WriteEndElement(); xw.WriteEndElement(); xw.WriteEndElement(); xw.Close(); }</pre> </div> </figure> </div> <div class="example-item" id="0xb6739f6711b27003d3f2104784cb802ad7321a8098a148db08eed78e7482cd4b-41,,100,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #7</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_7" data-hash="0xb6739f6711b27003d3f2104784cb802ad7321a8098a148db08eed78e7482cd4b" data-area="41,,100,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '7')" class="rating-up btn btn-success" data-id="rating_7"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'7')" class="rating-down btn btn-danger" data-id="rating_7"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xb6739f6711b27003d3f2104784cb802ad7321a8098a148db08eed78e7482cd4b-41,,100,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xb6739f6711b27003d3f2104784cb802ad7321a8098a148db08eed78e7482cd4b&fullName=QuizCreator%2FXMLUebersicht.xaml.cs&project=Chrisitanf%2Fmqcfjk')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FChrisitanf%2Fmqcfjk%2Fblob%2Fmaster%2FQuizCreator%2FXMLUebersicht.xaml.cs">XMLUebersicht.xaml.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FChrisitanf%2Fmqcfjk">Chrisitanf/mqcfjk</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="7"> <pre class="line-numbers language-csharp" data-end="100" data-start="42" data-highlight="75,76,77,78"> private void button1_Click(object sender, RoutedEventArgs e) { int dauer = 10; try { dauer = Convert.ToInt32(txt_dauer.Text); } catch (Exception) { } if (!Directory.Exists(Directory.GetCurrentDirectory() + "/quizxml/")) { Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/quizxml/"); } if (File.Exists(Directory.GetCurrentDirectory() + "/quizxml/" + txt_name.Text + ".xml")) { if (!bearbeiten) { MessageBox.Show("Ein Quiz mit diesem Namen existiert bereits! Bitte wählen Sie einen anderen Namen."); return; } } else { XmlTextWriter myXmlTextWriter = new XmlTextWriter(Directory.GetCurrentDirectory() + "/quizxml/" + txt_name.Text + ".xml", System.Text.Encoding.UTF8); myXmlTextWriter.Formatting = Formatting.Indented; myXmlTextWriter.WriteStartDocument(false); myXmlTextWriter.WriteStartElement("Quiz"); myXmlTextWriter.WriteElementString("quizname", txt_name.Text); myXmlTextWriter.WriteElementString("sounddatei", txt_name.Text + ".mp3"); myXmlTextWriter.WriteElementString("clipdauer", dauer.ToString()); myXmlTextWriter.WriteElementString("quiztyp", lb_kato.SelectedValue.ToString()); myXmlTextWriter.WriteStartElement("Items"); myXmlTextWriter.WriteEndElement(); myXmlTextWriter.WriteEndElement(); myXmlTextWriter.Close(); bearbeiten = true; } // index = 0 für sound if (lb_kato.SelectedIndex == 0) { MainWindow begriffe_window = new MainWindow(txt_name.Text); begriffe_window.Owner = this; begriffe_window.Show(); } // index = 1 für text if (lb_kato.SelectedIndex == 1) { fragenquiz begriffe_window = new fragenquiz(txt_name.Text); begriffe_window.Owner = this; begriffe_window.Show(); } }</pre> </div> </figure> </div> <div class="example-item" id="0xde1fb5f0afd18501d24c6dcea7bb86947007bd1aa6d3164803948d8dd4f9f87a-15,,45,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #8</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_8" data-hash="0xde1fb5f0afd18501d24c6dcea7bb86947007bd1aa6d3164803948d8dd4f9f87a" data-area="15,,45,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '8')" class="rating-up btn btn-success" data-id="rating_8"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'8')" class="rating-down btn btn-danger" data-id="rating_8"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xde1fb5f0afd18501d24c6dcea7bb86947007bd1aa6d3164803948d8dd4f9f87a-15,,45,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xde1fb5f0afd18501d24c6dcea7bb86947007bd1aa6d3164803948d8dd4f9f87a&fullName=SuperCrashTchrs%2FEndScreen.cs&project=caylascarrow%2FSuperCrashTchrs')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fcaylascarrow%2FSuperCrashTchrs%2Fblob%2Fmaster%2FSuperCrashTchrs%2FEndScreen.cs">EndScreen.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fcaylascarrow%2FSuperCrashTchrs">caylascarrow/SuperCrashTchrs</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="8"> <pre class="line-numbers language-csharp" data-end="45" data-start="16" data-highlight="41,43"> public EndScreen() { InitializeComponent(); try { XmlDocument doc = new XmlDocument(); doc.Load("recentlyPlayed.xml"); XmlNode parent; parent = doc.DocumentElement; //check each child of the parent element foreach (XmlNode child in parent.ChildNodes) { } } catch { XmlTextWriter writer = new XmlTextWriter("recentlyPlayed.xml", null); writer.WriteStartElement("recency"); writer.WriteElementString("winner", ""); writer.WriteElementString("loser", ""); } }</pre> </div> </figure> </div> <div class="example-item" id="0xadcd9314aff22e1a40c8a2ca2fe4f8f3f518e2a235bf653884e1e9e3cbe85e98-62,,94,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #9</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_9" data-hash="0xadcd9314aff22e1a40c8a2ca2fe4f8f3f518e2a235bf653884e1e9e3cbe85e98" data-area="62,,94,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '9')" class="rating-up btn btn-success" data-id="rating_9"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'9')" class="rating-down btn btn-danger" data-id="rating_9"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xadcd9314aff22e1a40c8a2ca2fe4f8f3f518e2a235bf653884e1e9e3cbe85e98-62,,94,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xadcd9314aff22e1a40c8a2ca2fe4f8f3f518e2a235bf653884e1e9e3cbe85e98&fullName=XMLWriter.cs&project=InhoChoi%2FKICOM')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FInhoChoi%2FKICOM%2Fblob%2Fmaster%2FXMLWriter.cs">XMLWriter.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FInhoChoi%2FKICOM">InhoChoi/KICOM</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="9"> <pre class="line-numbers language-csharp" data-end="94" data-start="63" data-highlight="82,83,84,86,89"> public void HistoryWriting(Result[] results) { foreach (Result result in results) { history.Enqueue(result); } //20개 갯수맞추기 while (true) { if (history.Count <= 20) { break; } history.Dequeue(); } using (XmlTextWriter writer = new XmlTextWriter("../../../Web/static/xml/history.xml", System.Text.Encoding.UTF8)) { writer.WriteStartDocument(); writer.Formatting = Formatting.Indented; writer.Indentation = 2; writer.WriteStartElement("History"); foreach (Result result in Enumerable.Reverse(history)) { writer.WriteStartElement("Info"); writer.WriteElementString("Name", result.name); writer.WriteElementString("Relation", result.relation); writer.WriteElementString("Photo_Path", Path.GetFileName(result.filepath)); if (result.date == null) { writer.WriteElementString("Date", System.DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss")); } else { writer.WriteElementString("Date", System.DateTime.Now.ToString(result.date)); } writer.WriteEndElement(); } writer.Close(); } }</pre> </div> </figure> </div> <div class="example-item" id="0x673039da41a6dc4b6dbc57ab53648545f60cb8db9b61d265129a56b9b9b50e8b-30,,60,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #10</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_10" data-hash="0x673039da41a6dc4b6dbc57ab53648545f60cb8db9b61d265129a56b9b9b50e8b" data-area="30,,60,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '10')" class="rating-up btn btn-success" data-id="rating_10"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'10')" class="rating-down btn btn-danger" data-id="rating_10"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x673039da41a6dc4b6dbc57ab53648545f60cb8db9b61d265129a56b9b9b50e8b-30,,60,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x673039da41a6dc4b6dbc57ab53648545f60cb8db9b61d265129a56b9b9b50e8b&fullName=02.+Processing+XML+in+.NET%2FTask7.cs&project=atanas-georgiev%2FDatabases-Homeworks')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fatanas-georgiev%2FDatabases-Homeworks%2Fblob%2Fmaster%2F02.+Processing+XML+in+.NET%2FTask7.cs">Task7.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fatanas-georgiev%2FDatabases-Homeworks">atanas-georgiev/Databases-Homeworks</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="10"> <pre class="line-numbers language-csharp" data-end="60" data-start="31" data-highlight="53,54,55"> /// <summary> /// The create xml from txt file. /// </summary> /// <param name="txtFile"> /// The txt file. /// </param> public static void CreateXmlFromTxtFile(string txtFile) { // In a text file we are given the name, address and phone number of given person (each at a single line). // Write a program, which creates new XML document, which contains these data in structured XML format. using (var reader = new StreamReader(txtFile)) { using (var writer = new XmlTextWriter(writeFileName, Encoding.UTF8)) { writer.Formatting = Formatting.Indented; writer.IndentChar = '\t'; writer.Indentation = 1; writer.WriteStartDocument(); writer.WriteStartElement("data"); writer.WriteStartElement("person"); writer.WriteElementString("name", reader.ReadLine()); writer.WriteElementString("address", reader.ReadLine()); writer.WriteElementString("gsm", reader.ReadLine()); writer.WriteEndElement(); writer.WriteEndDocument(); } } }</pre> </div> </figure> </div> <div class="example-item" id="0xee6d8b1d6b0372f9158a0363b52b7d705e9a86e922c2ec4b6f3ba90ec5485bc2-10,,44,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #11</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_11" data-hash="0xee6d8b1d6b0372f9158a0363b52b7d705e9a86e922c2ec4b6f3ba90ec5485bc2" data-area="10,,44,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '11')" class="rating-up btn btn-success" data-id="rating_11"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'11')" class="rating-down btn btn-danger" data-id="rating_11"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xee6d8b1d6b0372f9158a0363b52b7d705e9a86e922c2ec4b6f3ba90ec5485bc2-10,,44,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xee6d8b1d6b0372f9158a0363b52b7d705e9a86e922c2ec4b6f3ba90ec5485bc2&fullName=Databases%2FProcessing+XML+in+.NET%2FXMLProcessing%2FProgram.cs&project=MarinaGeorgieva%2FTelerikAcademy')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FMarinaGeorgieva%2FTelerikAcademy%2Fblob%2Fmaster%2FDatabases%2FProcessing+XML+in+.NET%2FXMLProcessing%2FProgram.cs">Program.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FMarinaGeorgieva%2FTelerikAcademy">MarinaGeorgieva/TelerikAcademy</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="11"> <pre class="line-numbers language-csharp" data-end="44" data-start="11" data-highlight="31,36"> public static void Main() { using (XmlTextWriter writer = new XmlTextWriter("../../albums.xml", Encoding.UTF8)) { writer.Formatting = Formatting.Indented; writer.IndentChar = '\t'; writer.Indentation = 1; writer.WriteStartDocument(); writer.WriteStartElement("albums"); using (XmlTextReader reader = new XmlTextReader("../../catalog.xml")) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "name") { writer.WriteStartElement("album"); writer.WriteElementString("name", reader.ReadElementString()); } if (reader.Name == "artist") { writer.WriteElementString("artist", reader.ReadElementString()); writer.WriteEndElement(); } } } } writer.WriteEndDocument(); } }</pre> </div> </figure> </div> <div class="example-item" id="0x57013d463ddfbfcacb90fb0875b36ea9c61bad55171d7402a594379a61f3b27f-35,,60,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #12</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_12" data-hash="0x57013d463ddfbfcacb90fb0875b36ea9c61bad55171d7402a594379a61f3b27f" data-area="35,,60,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '12')" class="rating-up btn btn-success" data-id="rating_12"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'12')" class="rating-down btn btn-danger" data-id="rating_12"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x57013d463ddfbfcacb90fb0875b36ea9c61bad55171d7402a594379a61f3b27f-35,,60,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x57013d463ddfbfcacb90fb0875b36ea9c61bad55171d7402a594379a61f3b27f&fullName=Settings.cs&project=Stricted%2FSpeedportHybridControl')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FStricted%2FSpeedportHybridControl%2Fblob%2Fmaster%2FSettings.cs">Settings.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FStricted%2FSpeedportHybridControl">Stricted/SpeedportHybridControl</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="12"> <pre class="line-numbers language-csharp" data-end="60" data-start="36" data-highlight="47,48"> public static bool save(SettingsModel settings) { bool result; try { using (XmlTextWriter xmlTextWriter = new XmlTextWriter("settings.xml", Encoding.UTF8)) { xmlTextWriter.Formatting = Formatting.Indented; xmlTextWriter.Indentation = 4; xmlTextWriter.WriteStartDocument(); xmlTextWriter.WriteStartElement("settings"); xmlTextWriter.WriteElementString("ip", settings.ip); xmlTextWriter.WriteElementString("password", Cryptography.Encrypt(settings.password)); xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteEndDocument(); } result = true; } catch (Exception exception) { LogManager.WriteToLog(exception.Message); result = false; } return result; }</pre> </div> </figure> </div> <div class="example-item" id="0x589cd26365e439c696e85e4a5263364eae8195b2d24e7fd01bf1c2408d98949a-55,,61,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #13</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_13" data-hash="0x589cd26365e439c696e85e4a5263364eae8195b2d24e7fd01bf1c2408d98949a" data-area="55,,61,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '13')" class="rating-up btn btn-success" data-id="rating_13"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'13')" class="rating-down btn btn-danger" data-id="rating_13"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x589cd26365e439c696e85e4a5263364eae8195b2d24e7fd01bf1c2408d98949a-55,,61,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x589cd26365e439c696e85e4a5263364eae8195b2d24e7fd01bf1c2408d98949a&fullName=Databases+Projects%2FHomework-ProcessingXMLIn.NET%2FCreateAlbumXMLDocument.cs&project=vladislav-karamfilov%2FTelerikAcademy')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fvladislav-karamfilov%2FTelerikAcademy%2Fblob%2Fmaster%2FDatabases+Projects%2FHomework-ProcessingXMLIn.NET%2FCreateAlbumXMLDocument.cs">CreateAlbumXMLDocument.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fvladislav-karamfilov%2FTelerikAcademy">vladislav-karamfilov/TelerikAcademy</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="13"> <pre class="line-numbers language-csharp" data-end="61" data-start="56" data-highlight="59,60"> static void WriteAlbum(XmlTextWriter writer, string name, string artist) { writer.WriteStartElement("album"); writer.WriteElementString("name", name); writer.WriteElementString("artist", artist); writer.WriteEndElement(); }</pre> </div> </figure> </div> <div class="example-item" id="0x53de752f0fa4bc55a537cdb59129b005fa8038c11cb803213d2f1ef53f76ba3d-15,,49,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #14</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_14" data-hash="0x53de752f0fa4bc55a537cdb59129b005fa8038c11cb803213d2f1ef53f76ba3d" data-area="15,,49,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '14')" class="rating-up btn btn-success" data-id="rating_14"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'14')" class="rating-down btn btn-danger" data-id="rating_14"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x53de752f0fa4bc55a537cdb59129b005fa8038c11cb803213d2f1ef53f76ba3d-15,,49,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x53de752f0fa4bc55a537cdb59129b005fa8038c11cb803213d2f1ef53f76ba3d&fullName=XmlProcessingInDotNet%2FStart.cs&project=NikolaiMishev%2FDatabases')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FNikolaiMishev%2FDatabases%2Fblob%2Fmaster%2FXmlProcessingInDotNet%2FStart.cs">Start.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FNikolaiMishev%2FDatabases">NikolaiMishev/Databases</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="14"> <pre class="line-numbers language-csharp" data-end="49" data-start="16" data-highlight="37,41"> private static void GenerateAlbum() { using (var writer = new XmlTextWriter("../../../AdditionalFiles/album.xml", Encoding.UTF8)) { writer.Formatting = Formatting.Indented; writer.IndentChar = '\t'; writer.Indentation = 1; writer.WriteStartDocument(); writer.WriteStartElement("albums"); using (XmlReader reader = XmlReader.Create("../../../AdditionalFiles/catalog.xml")) { while (reader.Read()) { bool isElement = reader.NodeType == XmlNodeType.Element; if (isElement && reader.Name == "name") { writer.WriteStartElement("album"); string albumName = reader.ReadElementContentAsString(); writer.WriteElementString("name", albumName); reader.ReadToFollowing("artist"); string albumAuthor = reader.ReadElementContentAsString(); writer.WriteElementString("author", albumAuthor); writer.WriteEndElement(); } } } writer.WriteEndElement(); } }</pre> </div> </figure> </div> <div class="example-item" id="0x4cbeb86deab995f3a2e08d38688631ab34258ce4180c4712f836b7ec7d7048d1-30,,63,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #15</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_15" data-hash="0x4cbeb86deab995f3a2e08d38688631ab34258ce4180c4712f836b7ec7d7048d1" data-area="30,,63,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '15')" class="rating-up btn btn-success" data-id="rating_15"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'15')" class="rating-down btn btn-danger" data-id="rating_15"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x4cbeb86deab995f3a2e08d38688631ab34258ce4180c4712f836b7ec7d7048d1-30,,63,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x4cbeb86deab995f3a2e08d38688631ab34258ce4180c4712f836b7ec7d7048d1&fullName=Program.cs&project=purplecow%2FMedia-Browser')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fpurplecow%2FMedia-Browser%2Fblob%2Fmaster%2FProgram.cs">Program.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fpurplecow%2FMedia-Browser">purplecow/Media-Browser</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="15"> <pre class="line-numbers language-csharp" data-end="63" data-start="31" data-highlight="49,50,51,52"> static void Main(string[] args) { if (args.Length != 1 || !Directory.Exists(args[0])) { Usage(); return; } string dir = args[0]; XmlTextWriter writer = new XmlTextWriter(PLUGIN_INFO ,Encoding.UTF8); writer.Formatting = Formatting.Indented; writer.Indentation = 3; writer.WriteStartElement("Plugins"); foreach (var file in Directory.GetFiles(dir)) { try { var plugin = Plugin.FromFile(file, false); writer.WriteStartElement("Plugin"); writer.WriteElementString("Version", plugin.Version.ToString()); writer.WriteElementString("Name", plugin.Name); writer.WriteElementString("Description", plugin.Description); writer.WriteElementString("Filename", Path.GetFileName(file)); writer.WriteEndElement(); } catch (Exception e) { Console.WriteLine("Failed to get infor for {0} : {1}", file, e); } } writer.WriteEndElement(); writer.Close(); Console.WriteLine("Wrote data to " + PLUGIN_INFO); }</pre> </div> </figure> </div> <div class="example-item" id="0xf0f0429b5de1492bf81df20062b9bfad4ad3b41608725eb92d017226212b9ace-68,,106,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #16</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_16" data-hash="0xf0f0429b5de1492bf81df20062b9bfad4ad3b41608725eb92d017226212b9ace" data-area="68,,106,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '16')" class="rating-up btn btn-success" data-id="rating_16"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'16')" class="rating-down btn btn-danger" data-id="rating_16"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xf0f0429b5de1492bf81df20062b9bfad4ad3b41608725eb92d017226212b9ace-68,,106,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xf0f0429b5de1492bf81df20062b9bfad4ad3b41608725eb92d017226212b9ace&fullName=win%2FCS%2FHandBrake.ApplicationServices%2FPlistUtility.cs&project=JuannyWang%2FHandBrake-QuickSync-Mac')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FJuannyWang%2FHandBrake-QuickSync-Mac%2Fblob%2Fmaster%2Fwin%2FCS%2FHandBrake.ApplicationServices%2FPlistUtility.cs">PlistUtility.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FJuannyWang%2FHandBrake-QuickSync-Mac">JuannyWang/HandBrake-QuickSync-Mac</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="16"> <pre class="line-numbers language-csharp" data-end="106" data-start="69" data-highlight="82,83,85,86,88,89,91,92,94,95,97,98,100,101,103,104"> /// <summary> /// Add an audio track /// </summary> /// <param name="xmlWriter"> /// The xml writer. /// </param> /// <param name="audioTrack"> /// The audio track. /// </param> private static void AddAudioItem(XmlTextWriter xmlWriter, AudioTrack audioTrack) { xmlWriter.WriteStartElement("dict"); xmlWriter.WriteElementString("key", "AudioBitrate"); xmlWriter.WriteElementString("string", audioTrack.Bitrate.ToString()); xmlWriter.WriteElementString("key", "AudioEncoder"); xmlWriter.WriteElementString("string", EnumHelper<AudioEncoder>.GetDisplay(audioTrack.Encoder)); xmlWriter.WriteElementString("key", "AudioMixdown"); xmlWriter.WriteElementString("string", EnumHelper<Mixdown>.GetDisplay(audioTrack.MixDown)); xmlWriter.WriteElementString("key", "AudioSamplerate"); xmlWriter.WriteElementString("string", audioTrack.SampleRate.ToString().Replace("0", "Auto")); xmlWriter.WriteElementString("key", "AudioTrack"); xmlWriter.WriteElementString("integer", audioTrack.Track.ToString()); xmlWriter.WriteElementString("key", "AudioTrackDRCSlider"); xmlWriter.WriteElementString("real", audioTrack.DRC.ToString()); xmlWriter.WriteElementString("key", "AudioTrackDescription"); xmlWriter.WriteElementString("string", "Unknown"); xmlWriter.WriteElementString("key", "AudioTrackGainSlider"); xmlWriter.WriteElementString("real", audioTrack.Gain.ToString()); xmlWriter.WriteEndElement(); }</pre> </div> </figure> </div> <div class="example-item" id="0xe69b2a5d514b2bd6e2a62dddb9f6b2dba344dbfed0ce8c15b87bcc787b410e9f-30,,64,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #17</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_17" data-hash="0xe69b2a5d514b2bd6e2a62dddb9f6b2dba344dbfed0ce8c15b87bcc787b410e9f" data-area="30,,64,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '17')" class="rating-up btn btn-success" data-id="rating_17"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'17')" class="rating-down btn btn-danger" data-id="rating_17"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xe69b2a5d514b2bd6e2a62dddb9f6b2dba344dbfed0ce8c15b87bcc787b410e9f-30,,64,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xe69b2a5d514b2bd6e2a62dddb9f6b2dba344dbfed0ce8c15b87bcc787b410e9f&fullName=nForum%2FRssHelper.cs&project=wakkomail%2Fcommunity-framework')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fwakkomail%2Fcommunity-framework%2Fblob%2Fmaster%2FnForum%2FRssHelper.cs">RssHelper.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fwakkomail%2Fcommunity-framework">wakkomail/community-framework</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="17"> <pre class="line-numbers language-csharp" data-end="64" data-start="31" data-highlight="44,45,58,61"> /// <summary> /// Adds a single item to the XmlTextWriter supplied /// </summary> /// <param name="writer">The XmlTextWriter to be written to</param> /// <param name="sItemTitle">The title of the RSS item</param> /// <param name="sItemLink">The URL of the RSS item</param> /// <param name="sItemDescription">The RSS item text itself</param> /// <param name="sPubDate"></param> /// <param name="bDescAsCdata">Write description as CDATA</param> /// <returns>The XmlTextWriter with the item info written to it</returns> public XmlTextWriter AddRssItem(XmlTextWriter writer, string sItemTitle, string sItemLink, string sItemDescription, DateTime sPubDate, bool bDescAsCdata) { writer.WriteStartElement("item"); writer.WriteElementString("title", sItemTitle); writer.WriteElementString("link", sItemLink); if (bDescAsCdata) { // Now we can write the description as CDATA to support html content. // We find this used quite often in aggregators writer.WriteStartElement("description"); writer.WriteCData(sItemDescription); writer.WriteEndElement(); } else { writer.WriteElementString("description", sItemDescription); } writer.WriteElementString("pubDate", sPubDate.ToString("r")); writer.WriteEndElement(); return writer; }</pre> </div> </figure> </div> <div class="example-item" id="0x702a2007f42ca07727586c9f92723af77a8df1b59b4235eaea19c9b084164697-48,,73,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #18</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_18" data-hash="0x702a2007f42ca07727586c9f92723af77a8df1b59b4235eaea19c9b084164697" data-area="48,,73,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '18')" class="rating-up btn btn-success" data-id="rating_18"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'18')" class="rating-down btn btn-danger" data-id="rating_18"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x702a2007f42ca07727586c9f92723af77a8df1b59b4235eaea19c9b084164697-48,,73,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x702a2007f42ca07727586c9f92723af77a8df1b59b4235eaea19c9b084164697&fullName=Source%2FCryptograph+Whois+Query%2FSettings.cs&project=niyazialpay%2FCryptograph-Whois-DNS-Tools')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fniyazialpay%2FCryptograph-Whois-DNS-Tools%2Fblob%2Fmaster%2FSource%2FCryptograph+Whois+Query%2FSettings.cs">Settings.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fniyazialpay%2FCryptograph-Whois-DNS-Tools">niyazialpay/Cryptograph-Whois-DNS-Tools</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="18"> <pre class="line-numbers language-csharp" data-end="73" data-start="49" data-highlight="58,59"> public bool SettingsWrite(string[] information) { XmlTextWriter xmlWrite = new XmlTextWriter(AppDomain.CurrentDomain.BaseDirectory + "\\settings.xml", System.Text.UTF8Encoding.UTF8); xmlWrite.Formatting = Formatting.Indented; try { xmlWrite.WriteStartDocument(); xmlWrite.WriteStartElement("root"); xmlWrite.WriteStartElement("settings"); xmlWrite.WriteElementString("server", information[0]); xmlWrite.WriteElementString("cache", information[1]); xmlWrite.WriteEndElement(); xmlWrite.WriteEndElement(); xmlWrite.Close(); DNS dns = new DNS(); dns._resolver.DnsServer = information[0]; dns._resolver.UseCache = Convert.ToBoolean(information[1]); return true; } catch (Exception ex) { Console.WriteLine("XML Error: " + ex.Message); return false; } }</pre> </div> </figure> </div> <div class="example-item" id="0xa0e392c4164f547b08bba135928eae85e8d0a9cf9a235b0b92b89d5c9f968205-60,,71,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #19</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_19" data-hash="0xa0e392c4164f547b08bba135928eae85e8d0a9cf9a235b0b92b89d5c9f968205" data-area="60,,71,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '19')" class="rating-up btn btn-success" data-id="rating_19"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'19')" class="rating-down btn btn-danger" data-id="rating_19"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xa0e392c4164f547b08bba135928eae85e8d0a9cf9a235b0b92b89d5c9f968205-60,,71,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xa0e392c4164f547b08bba135928eae85e8d0a9cf9a235b0b92b89d5c9f968205&fullName=SupportFiles%2FNTS+1.7.3+Build+416%2FNetTopologySuite%2FIO%2FGMLWriter.cs&project=DIVEROVIEDO%2FDotSpatial')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FDIVEROVIEDO%2FDotSpatial%2Fblob%2Fmaster%2FSupportFiles%2FNTS+1.7.3+Build+416%2FNetTopologySuite%2FIO%2FGMLWriter.cs">GMLWriter.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FDIVEROVIEDO%2FDotSpatial">DIVEROVIEDO/DotSpatial</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="19"> <pre class="line-numbers language-csharp" data-end="71" data-start="61" data-highlight="69,70"> /// <summary> /// /// </summary> /// <param name="coordinate"></param> /// <param name="writer"></param> protected void Write(ICoordinate coordinate, XmlTextWriter writer) { writer.WriteStartElement(GMLElements.gmlPrefix, "coord", GMLElements.gmlNS); writer.WriteElementString(GMLElements.gmlPrefix, "X", GMLElements.gmlNS, coordinate.X.ToString("g", NumberFormatter)); writer.WriteElementString(GMLElements.gmlPrefix, "Y", GMLElements.gmlNS, coordinate.Y.ToString("g", NumberFormatter)); writer.WriteEndElement(); }</pre> </div> </figure> </div> <div class="example-item" id="0xea9bdda5df09a91bdcb5bda5cb3e20a56f458e63e40d3248f5f59cc17578fbaf-9,,40,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #20</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_20" data-hash="0xea9bdda5df09a91bdcb5bda5cb3e20a56f458e63e40d3248f5f59cc17578fbaf" data-area="9,,40,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '20')" class="rating-up btn btn-success" data-id="rating_20"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'20')" class="rating-down btn btn-danger" data-id="rating_20"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xea9bdda5df09a91bdcb5bda5cb3e20a56f458e63e40d3248f5f59cc17578fbaf-9,,40,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xea9bdda5df09a91bdcb5bda5cb3e20a56f458e63e40d3248f5f59cc17578fbaf&fullName=Database%2FHomeworks%2F02.+Processing+XML+in+.NET%2FProcessing+XML+in+.NET%2FTask07.cs&project=EmilMitev%2FTelerik-Academy')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FEmilMitev%2FTelerik-Academy%2Fblob%2Fmaster%2FDatabase%2FHomeworks%2F02.+Processing+XML+in+.NET%2FProcessing+XML+in+.NET%2FTask07.cs">Task07.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FEmilMitev%2FTelerik-Academy">EmilMitev/Telerik-Academy</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="20"> <pre class="line-numbers language-csharp" data-end="40" data-start="10" data-highlight="30,31,32"> public static void ConvetTextToXml() { string[] lines; const int NumberOfTagsForEachPerson = 3; using (var writer = new XmlTextWriter("../../toXml.xml", Encoding.UTF8)) { writer.Formatting = Formatting.Indented; writer.IndentChar = '\t'; writer.Indentation = 1; using (StreamReader reader = new StreamReader("../../fromText.txt")) { lines = reader.ReadToEnd().Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); writer.WriteStartDocument(); writer.WriteStartElement("Persons"); for (int i = 0; i < lines.Length; i += NumberOfTagsForEachPerson) { writer.WriteStartElement("Person"); writer.WriteElementString("name", lines[i]); writer.WriteElementString("adress", lines[i + 1]); writer.WriteElementString("telephone", lines[i + 2]); writer.WriteEndElement(); } writer.WriteEndElement(); } } Console.WriteLine("\tDONE!!! Check file!"); }</pre> </div> </figure> </div> <div class="example-item" id="0xad3d92906978703ec51e648916220addfcc4d6aecb11d2db5710b33636ef088b-66,,94,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #21</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_21" data-hash="0xad3d92906978703ec51e648916220addfcc4d6aecb11d2db5710b33636ef088b" data-area="66,,94,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '21')" class="rating-up btn btn-success" data-id="rating_21"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'21')" class="rating-down btn btn-danger" data-id="rating_21"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xad3d92906978703ec51e648916220addfcc4d6aecb11d2db5710b33636ef088b-66,,94,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xad3d92906978703ec51e648916220addfcc4d6aecb11d2db5710b33636ef088b&fullName=Projects%2FUmbraco6%2FBlogs%2Fsrc%2FUmlaut.Umb.Blog%2FAutoping.cs&project=phaniarveti%2FExperiments')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fphaniarveti%2FExperiments%2Fblob%2Fmaster%2FProjects%2FUmbraco6%2FBlogs%2Fsrc%2FUmlaut.Umb.Blog%2FAutoping.cs">Autoping.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fphaniarveti%2FExperiments">phaniarveti/Experiments</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="21"> <pre class="line-numbers language-csharp" data-end="94" data-start="67" data-highlight="77,80,84"> private void PingService(string ping, string name, string url) { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ping); request.Method = "POST"; request.ContentType = "text/xml"; using (Stream stream = (Stream)request.GetRequestStream()) { using (XmlTextWriter xml = new XmlTextWriter(stream, Encoding.UTF8)) { xml.WriteStartDocument(); xml.WriteStartElement("methodCall"); xml.WriteElementString("methodName", "weblogUpdates.ping"); xml.WriteStartElement("params"); xml.WriteStartElement("param"); xml.WriteElementString("value", name); xml.WriteEndElement(); xml.WriteStartElement("param"); xml.WriteElementString("value", url); xml.WriteEndElement(); xml.WriteEndElement(); xml.WriteEndElement(); xml.WriteEndDocument(); } } } catch (Exception ex) { Log.Add(LogTypes.Debug, -1, "pinger: url: " + ping + " exception:" + ex.ToString()); } }</pre> </div> </figure> </div> <div class="example-item" id="0x8a4bf691409a137de6ddfad5ccef115cce3ba9d6bfa86a43fa921124a1b7bc57-66,,95,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #22</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_22" data-hash="0x8a4bf691409a137de6ddfad5ccef115cce3ba9d6bfa86a43fa921124a1b7bc57" data-area="66,,95,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '22')" class="rating-up btn btn-success" data-id="rating_22"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'22')" class="rating-down btn btn-danger" data-id="rating_22"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x8a4bf691409a137de6ddfad5ccef115cce3ba9d6bfa86a43fa921124a1b7bc57-66,,95,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x8a4bf691409a137de6ddfad5ccef115cce3ba9d6bfa86a43fa921124a1b7bc57&fullName=Websites%2FThon.NET%2FThon.ZaszBlog.Support%2FPingback.cs&project=chandru9279%2FStarBase')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fchandru9279%2FStarBase%2Fblob%2Fmaster%2FWebsites%2FThon.NET%2FThon.ZaszBlog.Support%2FPingback.cs">Pingback.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fchandru9279%2FStarBase">chandru9279/StarBase</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="22"> <pre class="line-numbers language-csharp" data-end="95" data-start="67" data-highlight="78,83,89"> /// <summary> /// Adds the XML to web request. The XML is the standard /// XML used by RPC-XML requests. /// </summary> private static void AddXmlToRequest(Uri sourceUrl, Uri targetUrl, HttpWebRequest webreqPing) { Stream stream = (Stream)webreqPing.GetRequestStream(); using (XmlTextWriter writer = new XmlTextWriter(stream, Encoding.ASCII)) { writer.WriteStartDocument(true); writer.WriteStartElement("methodCall"); writer.WriteElementString("methodName", "pingback.ping"); writer.WriteStartElement("params"); writer.WriteStartElement("param"); writer.WriteStartElement("value"); writer.WriteElementString("string", sourceUrl.ToString()); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteStartElement("param"); writer.WriteStartElement("value"); writer.WriteElementString("string", targetUrl.ToString()); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndElement(); } }</pre> </div> </figure> </div> <div class="example-item" id="0xafe8307e6f0b169ccfab641ee196a6ab78a54edf408b1cdf2fe550d7a75940b5-13,,44,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #23</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_23" data-hash="0xafe8307e6f0b169ccfab641ee196a6ab78a54edf408b1cdf2fe550d7a75940b5" data-area="13,,44,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '23')" class="rating-up btn btn-success" data-id="rating_23"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'23')" class="rating-down btn btn-danger" data-id="rating_23"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xafe8307e6f0b169ccfab641ee196a6ab78a54edf408b1cdf2fe550d7a75940b5-13,,44,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xafe8307e6f0b169ccfab641ee196a6ab78a54edf408b1cdf2fe550d7a75940b5&fullName=Databases%2F02.ProcesingXML%2FCreateAlbum.cs&project=radkomitev%2FTelerik-Academy')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fradkomitev%2FTelerik-Academy%2Fblob%2Fmaster%2FDatabases%2F02.ProcesingXML%2FCreateAlbum.cs">CreateAlbum.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fradkomitev%2FTelerik-Academy">radkomitev/Telerik-Academy</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="23"> <pre class="line-numbers language-csharp" data-end="44" data-start="14" data-highlight="34,38"> static void Main() { string fileName = "../../album.xml"; Encoding encoding = Encoding.GetEncoding("windows-1251"); using (XmlTextWriter writer = new XmlTextWriter(fileName, encoding)) { writer.Formatting = Formatting.Indented; writer.IndentChar = '\t'; writer.Indentation = 2; writer.WriteStartDocument(); writer.WriteStartElement("albums"); using (XmlReader reader = XmlReader.Create("../../../catalogue.xml")) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.Name == "name") { writer.WriteStartElement("album"); writer.WriteElementString("name", reader.ReadElementString()); } else if (reader.NodeType == XmlNodeType.Element && reader.Name == "artist") { writer.WriteElementString("artist", reader.ReadElementString()); writer.WriteEndElement(); } } } Console.WriteLine("Finish"); } }</pre> </div> </figure> </div> <div class="example-item" id="0x91cdb4fdf7a66d78424e1fb58d7497ef609382b6e4a1b7d2ade73bcba89a77db-16,,50,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #24</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_24" data-hash="0x91cdb4fdf7a66d78424e1fb58d7497ef609382b6e4a1b7d2ade73bcba89a77db" data-area="16,,50,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '24')" class="rating-up btn btn-success" data-id="rating_24"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'24')" class="rating-down btn btn-danger" data-id="rating_24"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x91cdb4fdf7a66d78424e1fb58d7497ef609382b6e4a1b7d2ade73bcba89a77db-16,,50,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x91cdb4fdf7a66d78424e1fb58d7497ef609382b6e4a1b7d2ade73bcba89a77db&fullName=02.XMLProcessing%2FProgram.cs&project=plamenti%2FTelerik2015-Databases')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fplamenti%2FTelerik2015-Databases%2Fblob%2Fmaster%2F02.XMLProcessing%2FProgram.cs">Program.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fplamenti%2FTelerik2015-Databases">plamenti/Telerik2015-Databases</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="24"> <pre class="line-numbers language-csharp" data-end="50" data-start="17" data-highlight="39,43"> private static void Main(string[] args) { // 8. Write a program, which (using XmlReader and XmlWriter) reads the file catalog.xml and creates the file album.xml, // in which stores in appropriate way the names of all albums and their authors Encoding encoding = Encoding.UTF8; using (XmlTextWriter writer = new XmlTextWriter(FileToWrite, encoding)) { writer.Formatting = Formatting.Indented; writer.IndentChar = '\t'; writer.Indentation = 1; writer.WriteStartDocument(); writer.WriteStartElement("albums"); using (XmlTextReader reader = new XmlTextReader(FileToRead)) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.Name == "name") { writer.WriteStartElement("album"); writer.WriteElementString("name", reader.ReadElementString()); } else if (reader.NodeType == XmlNodeType.Element && reader.Name == "artist") { writer.WriteElementString("artist", reader.ReadElementString()); writer.WriteEndElement(); } } } writer.WriteEndDocument(); } }</pre> </div> </figure> </div> <div class="example-item" id="0xdabd07f19620e4db7b3a5d57b45a8b01ae01709756bec2947ece2d47cd7d9983-58,,96,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #25</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_25" data-hash="0xdabd07f19620e4db7b3a5d57b45a8b01ae01709756bec2947ece2d47cd7d9983" data-area="58,,96,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '25')" class="rating-up btn btn-success" data-id="rating_25"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'25')" class="rating-down btn btn-danger" data-id="rating_25"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xdabd07f19620e4db7b3a5d57b45a8b01ae01709756bec2947ece2d47cd7d9983-58,,96,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xdabd07f19620e4db7b3a5d57b45a8b01ae01709756bec2947ece2d47cd7d9983&fullName=MrCMS.Web%2FApps%2FEcommerce%2FServices%2FGoogleBaseManager.cs&project=neozhu%2FEcommerce')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fneozhu%2FEcommerce%2Fblob%2Fmaster%2FMrCMS.Web%2FApps%2FEcommerce%2FServices%2FGoogleBaseManager.cs">GoogleBaseManager.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fneozhu%2FEcommerce">neozhu/Ecommerce</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="25"> <pre class="line-numbers language-csharp" data-end="96" data-start="59" data-highlight="76,77,78"> /// <summary> /// Export Products To Google Base /// </summary> /// <returns></returns> public byte[] ExportProductsToGoogleBase() { const string ns = "http://base.google.com/ns/1.0"; var ms = new MemoryStream(); var xml = new XmlTextWriter(ms, Encoding.UTF8); xml.WriteStartDocument(); xml.WriteStartElement("rss"); xml.WriteAttributeString("xmlns", "g", null, ns); xml.WriteAttributeString("version", "2.0"); xml.WriteStartElement("channel"); //GENERAL FEED INFO xml.WriteElementString("title", CurrentRequestData.CurrentSite.Name); xml.WriteElementString("link", CurrentRequestData.CurrentSite.BaseUrl); xml.WriteElementString("description", " Products from " + CurrentRequestData.CurrentSite.Name + " online store"); IList<ProductVariant> productVariants = _productVariantService.GetAllVariantsForGoogleBase(); foreach (ProductVariant pv in productVariants) { ExportGoogleBaseProduct(ref xml, pv, ns); } xml.WriteEndElement(); xml.WriteEndElement(); xml.WriteEndDocument(); xml.Flush(); byte[] file = ms.ToArray(); xml.Close(); return file; }</pre> </div> </figure> </div> <div class="example-item" id="0xe6a9b1b91425851cac5aaef19f33f01966b23dc921e3ce04cff39036af2cf71d-20,,54,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #26</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_26" data-hash="0xe6a9b1b91425851cac5aaef19f33f01966b23dc921e3ce04cff39036af2cf71d" data-area="20,,54,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '26')" class="rating-up btn btn-success" data-id="rating_26"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'26')" class="rating-down btn btn-danger" data-id="rating_26"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xe6a9b1b91425851cac5aaef19f33f01966b23dc921e3ce04cff39036af2cf71d-20,,54,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xe6a9b1b91425851cac5aaef19f33f01966b23dc921e3ce04cff39036af2cf71d&fullName=Databases%2FXML-Processing%2FCatalogueToAlbums.cs&project=InKolev%2FTelerikAcademy')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FInKolev%2FTelerikAcademy%2Fblob%2Fmaster%2FDatabases%2FXML-Processing%2FCatalogueToAlbums.cs">CatalogueToAlbums.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FInKolev%2FTelerikAcademy">InKolev/TelerikAcademy</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="26"> <pre class="line-numbers language-csharp" data-end="54" data-start="21" data-highlight="40,44"> static void Main(string[] args) { using (XmlTextWriter writer = new XmlTextWriter(OutputPath, Encoding.UTF8)) { writer.Formatting = Formatting.Indented; writer.Indentation = 4; writer.IndentChar = ' '; writer.WriteStartDocument(); writer.WriteStartElement("albums"); using (XmlReader reader = XmlReader.Create(InputPath)) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == "name") { writer.WriteStartElement("album"); writer.WriteElementString("name", reader.ReadElementString()); } else if (reader.Name == "artist") { writer.WriteElementString("artist", reader.ReadElementString()); writer.WriteEndElement(); } } } } writer.WriteEndDocument(); } Console.WriteLine("Parsing is finished. Your document is ready."); }</pre> </div> </figure> </div> <div class="example-item" id="0xba37a62ac13aceda5410b1c97e1efb9ef231c4b32f4c15f156866e2afa02bcbc-15,,44,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #27</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_27" data-hash="0xba37a62ac13aceda5410b1c97e1efb9ef231c4b32f4c15f156866e2afa02bcbc" data-area="15,,44,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '27')" class="rating-up btn btn-success" data-id="rating_27"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'27')" class="rating-down btn btn-danger" data-id="rating_27"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xba37a62ac13aceda5410b1c97e1efb9ef231c4b32f4c15f156866e2afa02bcbc-15,,44,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xba37a62ac13aceda5410b1c97e1efb9ef231c4b32f4c15f156866e2afa02bcbc&fullName=as_put.cs&project=smccaula%2FMidiEvolution')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fsmccaula%2FMidiEvolution%2Fblob%2Fmaster%2Fas_put.cs">as_put.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fsmccaula%2FMidiEvolution">smccaula/MidiEvolution</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="27"> <pre class="line-numbers language-csharp" data-end="44" data-start="16" data-highlight="32,33"> static void ImportXMLfile(int popMember) { string filename = ""; filename = GlobalVar.jobName + GlobalVar.popIndex.ToString() + popMember.ToString(); XmlTextWriter xml = null; xml = new XmlTextWriter(filename, null); xml.WriteStartDocument(); xml.WriteStartElement("Features"); xml.WriteWhitespace("\n"); for (int i = 0; i < GlobalVar.featureCount; i++) { xml.WriteElementString("Index", i.ToString()); xml.WriteElementString("Value", GlobalVar.features[i].ToString()); xml.WriteWhitespace("\n "); } xml.WriteEndElement(); xml.WriteWhitespace("\n"); xml.WriteEndDocument(); //Write the XML to file and close the writer. xml.Flush(); xml.Close(); }</pre> </div> </figure> </div> <div class="example-item" id="0x9ea8f3fa3d2a6f76fa12521d8533b029f8a88807ebe482ef7d21fb7ec956019d-13,,44,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #28</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_28" data-hash="0x9ea8f3fa3d2a6f76fa12521d8533b029f8a88807ebe482ef7d21fb7ec956019d" data-area="13,,44,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '28')" class="rating-up btn btn-success" data-id="rating_28"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'28')" class="rating-down btn btn-danger" data-id="rating_28"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x9ea8f3fa3d2a6f76fa12521d8533b029f8a88807ebe482ef7d21fb7ec956019d-13,,44,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x9ea8f3fa3d2a6f76fa12521d8533b029f8a88807ebe482ef7d21fb7ec956019d&fullName=11.DataBases%2C+SQL%2C+SQL+Server%2F12.XmlProcessingIn.Net%2FExtractCatalogue.cs&project=Nottyy%2FTelerikAcademy')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FNottyy%2FTelerikAcademy%2Fblob%2Fmaster%2F11.DataBases%2C+SQL%2C+SQL+Server%2F12.XmlProcessingIn.Net%2FExtractCatalogue.cs">ExtractCatalogue.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FNottyy%2FTelerikAcademy">Nottyy/TelerikAcademy</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="28"> <pre class="line-numbers language-csharp" data-end="44" data-start="14" data-highlight="39,40"> public static void Main() { XmlReader reader = XmlReader.Create("..\\..\\..\\XmlCatalogDirectory\\text.xml"); XmlTextWriter writer = new XmlTextWriter("..\\..\\album.xml",Encoding.UTF8); using (writer) { writer.WriteStartDocument(); writer.Formatting = Formatting.Indented; writer.IndentChar = '\t'; writer.Indentation = 1; writer.WriteStartElement("albums"); string artist = ""; while (reader.Read()) { if ((reader.NodeType == XmlNodeType.Element) && reader.Name == "artist") { artist = reader.GetAttribute("name"); } else if ((reader.NodeType == XmlNodeType.Element) && reader.Name == "name") { string albumName = reader.ReadElementContentAsString(); writer.WriteStartElement("album"); writer.WriteElementString("name", albumName); writer.WriteElementString("artist", artist); writer.WriteEndElement(); } } } }</pre> </div> </figure> </div> <div class="example-item" id="0xd60784eac156560b600f23f44ef463f77860334f4c527e38432d75291402de40-62,,87,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #29</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_29" data-hash="0xd60784eac156560b600f23f44ef463f77860334f4c527e38432d75291402de40" data-area="62,,87,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '29')" class="rating-up btn btn-success" data-id="rating_29"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'29')" class="rating-down btn btn-danger" data-id="rating_29"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xd60784eac156560b600f23f44ef463f77860334f4c527e38432d75291402de40-62,,87,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xd60784eac156560b600f23f44ef463f77860334f4c527e38432d75291402de40&fullName=Utilities.Web%2FWeb%2FManager.cs&project=Adilson%2FCraig-s-Utility-Library')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FAdilson%2FCraig-s-Utility-Library%2Fblob%2Fmaster%2FUtilities.Web%2FWeb%2FManager.cs">Manager.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FAdilson%2FCraig-s-Utility-Library">Adilson/Craig-s-Utility-Library</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="29"> <pre class="line-numbers language-csharp" data-end="87" data-start="63" data-highlight="76,79,82"> private static void PingServices(IEnumerable<Uri> Services, Uri Blog, string BlogName) { foreach (Uri Service in Services) { HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(Service); Request.Credentials = CredentialCache.DefaultNetworkCredentials; Request.ContentType = "text/xml"; Request.Method = "POST"; Request.Timeout = 10000; using (XmlTextWriter XMLWriter = new XmlTextWriter(Request.GetRequestStream(), Encoding.ASCII)) { XMLWriter.WriteStartDocument(); XMLWriter.WriteStartElement("methodCall"); XMLWriter.WriteElementString("methodName", "weblogUpdates.ping"); XMLWriter.WriteStartElement("params"); XMLWriter.WriteStartElement("param"); XMLWriter.WriteElementString("value", BlogName); XMLWriter.WriteEndElement(); XMLWriter.WriteStartElement("param"); XMLWriter.WriteElementString("value", Blog.ToString()); XMLWriter.WriteEndElement(); XMLWriter.WriteEndElement(); XMLWriter.WriteEndElement(); } } }</pre> </div> </figure> </div> <div class="example-item" id="0x9f79755b67c595327ff8e23b350051c539952bd51c233d6a8643fe50c459fc22-44,,82,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #30</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_30" data-hash="0x9f79755b67c595327ff8e23b350051c539952bd51c233d6a8643fe50c459fc22" data-area="44,,82,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '30')" class="rating-up btn btn-success" data-id="rating_30"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'30')" class="rating-down btn btn-danger" data-id="rating_30"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x9f79755b67c595327ff8e23b350051c539952bd51c233d6a8643fe50c459fc22-44,,82,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x9f79755b67c595327ff8e23b350051c539952bd51c233d6a8643fe50c459fc22&fullName=Framework%2FReadWriterXml.cs&project=xlgwr%2Fproducting')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fxlgwr%2Fproducting%2Fblob%2Fmaster%2FFramework%2FReadWriterXml.cs">ReadWriterXml.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fxlgwr%2Fproducting">xlgwr/producting</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="30"> <pre class="line-numbers language-csharp" data-end="82" data-start="45" data-highlight="68,69"> /// <summary> /// 写入配置参数数据 /// </summary> /// <param name="Path"></param> public void WriterXml(string Path) { try { // 创建XmlTextWriter类的实例对象 XmlTextWriter textWriter = new XmlTextWriter(Path, null); textWriter.Formatting = Formatting.Indented; // 开始写过程,调用WriteStartDocument方法 textWriter.WriteStartDocument(); // 写入说明 textWriter.WriteComment("First Comment XmlTextWriter Sample Example"); textWriter.WriteComment("w3sky.xml in root dir"); //创建一个节点 textWriter.WriteStartElement("Administrator"); textWriter.WriteElementString("Name", "formble"); textWriter.WriteElementString("site", "w3sky.com"); textWriter.WriteEndElement(); // 写文档结束,调用WriteEndDocument方法 textWriter.WriteEndDocument(); // 关闭textWriter textWriter.Close(); } catch (System.Exception e) { Console.WriteLine(e.ToString()); } }</pre> </div> </figure> </div> <div class="example-item" id="0xca9e142aa7a29e740922ad917514b3c41a38d79407a0ae5c12a51eddbe735b3c-20,,66,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #31</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_31" data-hash="0xca9e142aa7a29e740922ad917514b3c41a38d79407a0ae5c12a51eddbe735b3c" data-area="20,,66,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '31')" class="rating-up btn btn-success" data-id="rating_31"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'31')" class="rating-down btn btn-danger" data-id="rating_31"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xca9e142aa7a29e740922ad917514b3c41a38d79407a0ae5c12a51eddbe735b3c-20,,66,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xca9e142aa7a29e740922ad917514b3c41a38d79407a0ae5c12a51eddbe735b3c&fullName=App%2Fsrc%2FXmlTools.cs&project=appliedi%2FMerchantTribe')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fappliedi%2FMerchantTribe%2Fblob%2Fmaster%2FApp%2Fsrc%2FXmlTools.cs">XmlTools.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fappliedi%2FMerchantTribe">appliedi/MerchantTribe</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="31"> <pre class="line-numbers language-csharp" data-end="66" data-start="21" data-highlight="48,49,50"> /// ----------------------------------------------------------------------------- /// <summary> /// builds XML access key for UPS requests /// </summary> /// <param name="settings"></param> /// <returns></returns> /// <remarks> /// </remarks> /// <history> /// [mmcconnell] 11/1/2004 Created /// </history> /// ----------------------------------------------------------------------------- public static string BuildAccessKey(UpsSettings settings) { string sXML = ""; StringWriter strWriter = new StringWriter(); XmlTextWriter xw = new XmlTextWriter(strWriter); xw.Formatting = Formatting.Indented; xw.Indentation = 3; xw.WriteStartDocument(); //-------------------------------------------- // Agreement Request xw.WriteStartElement("AccessRequest"); xw.WriteElementString("AccessLicenseNumber", settings.License); xw.WriteElementString("UserId", settings.UserID); xw.WriteElementString("Password", settings.Password); xw.WriteEndElement(); // End Agreement Request //-------------------------------------------- xw.WriteEndDocument(); xw.Flush(); xw.Close(); sXML = strWriter.GetStringBuilder().ToString(); xw = null; //HttpContext.Current.Trace.Write("AccessRequest=" & sXML) return sXML; }</pre> </div> </figure> </div> <div class="example-item" id="0x191b590b8f406c0f7b0cf8beb59a9802c51e232d1e7b8a2d0aca59f39a86edb1-409,,442,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #32</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_32" data-hash="0x191b590b8f406c0f7b0cf8beb59a9802c51e232d1e7b8a2d0aca59f39a86edb1" data-area="409,,442,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '32')" class="rating-up btn btn-success" data-id="rating_32"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'32')" class="rating-down btn btn-danger" data-id="rating_32"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x191b590b8f406c0f7b0cf8beb59a9802c51e232d1e7b8a2d0aca59f39a86edb1-409,,442,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x191b590b8f406c0f7b0cf8beb59a9802c51e232d1e7b8a2d0aca59f39a86edb1')">Show file</a> </div> <div class="example-project-info"> <nobr> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect"></a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="32"> <pre class="line-numbers language-csharp" data-end="442" data-start="410" data-highlight="427,429,430"> private void SavePluginListToXMLFile(string filename) { try { Console.WriteLine("Saving plugins entries to " + (string)MediaNET.Config["Interface/plugins.xml"]); XmlTextWriter writer = new System.Xml.XmlTextWriter((string)MediaNET.Config["Interface/plugins.xml"], null); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteStartElement("plugins"); TreeModel model = pluginList.Model; TreeIter iter; if (pluginStore.GetIterFirst(out iter)) { do { writer.WriteStartElement("plugin"); writer.WriteElementString("extension", (string)model.GetValue(iter, 0)); // Second field ignored -> found using reflection writer.WriteElementString("player", (string)model.GetValue(iter, 2)); writer.WriteElementString("path", (string)model.GetValue(iter, 3)); writer.WriteEndElement(); }while (pluginStore.IterNext(ref iter)); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); writer.Close(); } catch (Exception e) { throw new Exception("Save settings failed: " + e.Message); } }</pre> </div> </figure> </div> <div class="example-item" id="0x2f865ad901415c783136f9cf06499893379acb93ae1c1e57cc3e269982cde005-424,,472,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #33</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_33" data-hash="0x2f865ad901415c783136f9cf06499893379acb93ae1c1e57cc3e269982cde005" data-area="424,,472,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '33')" class="rating-up btn btn-success" data-id="rating_33"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'33')" class="rating-down btn btn-danger" data-id="rating_33"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x2f865ad901415c783136f9cf06499893379acb93ae1c1e57cc3e269982cde005-424,,472,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x2f865ad901415c783136f9cf06499893379acb93ae1c1e57cc3e269982cde005')">Show file</a> </div> <div class="example-project-info"> <nobr> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect"></a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="33"> <pre class="line-numbers language-csharp" data-end="472" data-start="425" data-highlight="465,469"> public static void SaveToXml(System.Xml.XmlTextWriter xmlWriter, IImageSet imageset, string alternateUrl) { xmlWriter.WriteStartElement("ImageSet"); xmlWriter.WriteAttributeString("Generic", imageset.Generic.ToString()); xmlWriter.WriteAttributeString("DataSetType", imageset.DataSetType.ToString()); xmlWriter.WriteAttributeString("BandPass", imageset.BandPass.ToString()); if (!imageset.Generic) { xmlWriter.WriteAttributeString("Name", imageset.Name); if (String.IsNullOrEmpty(alternateUrl)) { xmlWriter.WriteAttributeString("Url", imageset.Url); } else { xmlWriter.WriteAttributeString("Url", alternateUrl); } xmlWriter.WriteAttributeString("DemUrl", imageset.DemUrl); xmlWriter.WriteAttributeString("BaseTileLevel", imageset.BaseLevel.ToString()); xmlWriter.WriteAttributeString("TileLevels", imageset.Levels.ToString()); xmlWriter.WriteAttributeString("BaseDegreesPerTile", imageset.BaseTileDegrees.ToString()); xmlWriter.WriteAttributeString("FileType", imageset.Extension); xmlWriter.WriteAttributeString("BottomsUp", imageset.BottomsUp.ToString()); xmlWriter.WriteAttributeString("Projection", imageset.Projection.ToString()); xmlWriter.WriteAttributeString("QuadTreeMap", imageset.QuadTreeTileMap); xmlWriter.WriteAttributeString("CenterX", imageset.CenterX.ToString()); xmlWriter.WriteAttributeString("CenterY", imageset.CenterY.ToString()); xmlWriter.WriteAttributeString("OffsetX", imageset.OffsetX.ToString()); xmlWriter.WriteAttributeString("OffsetY", imageset.OffsetY.ToString()); xmlWriter.WriteAttributeString("Rotation", imageset.Rotation.ToString()); xmlWriter.WriteAttributeString("Sparse", imageset.Sparse.ToString()); xmlWriter.WriteAttributeString("ElevationModel", imageset.ElevationModel.ToString()); xmlWriter.WriteAttributeString("StockSet", imageset.DefaultSet.ToString()); xmlWriter.WriteAttributeString("WidthFactor", imageset.WidthFactor.ToString()); xmlWriter.WriteAttributeString("MeanRadius", imageset.MeanRadius.ToString()); xmlWriter.WriteAttributeString("ReferenceFrame", imageset.ReferenceFrame); if (String.IsNullOrEmpty(alternateUrl)) { xmlWriter.WriteElementString("ThumbnailUrl", imageset.ThumbnailUrl); } else { xmlWriter.WriteElementString("ThumbnailUrl", imageset.Url); } } xmlWriter.WriteEndElement(); }</pre> </div> </figure> </div> <div class="example-item" id="0x4153cba418e0434aa9a2a08b7c1b420fd4a087b18b51427fea6835598579f487-10,,34,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #34</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_34" data-hash="0x4153cba418e0434aa9a2a08b7c1b420fd4a087b18b51427fea6835598579f487" data-area="10,,34,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '34')" class="rating-up btn btn-success" data-id="rating_34"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'34')" class="rating-down btn btn-danger" data-id="rating_34"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x4153cba418e0434aa9a2a08b7c1b420fd4a087b18b51427fea6835598579f487-10,,34,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x4153cba418e0434aa9a2a08b7c1b420fd4a087b18b51427fea6835598579f487')">Show file</a> </div> <div class="example-project-info"> <nobr> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect"></a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="34"> <pre class="line-numbers language-csharp" data-end="34" data-start="11" data-highlight="28"> public static void WriteXmlInFile(string layer, string msg) { try { //XmlDataDocument sourceXML = new XmlDataDocument(); string xmlFile = HttpContext.Current.Server.MapPath("/log/Exception.xml"); //create a XML file is not exist System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(xmlFile, null); //starts a new document writer.WriteStartDocument(); //write comments writer.WriteComment("Commentss: XmlWriter Test Program"); writer.Formatting = Formatting.Indented; writer.WriteStartElement("MessageList"); writer.WriteStartElement("Exception"); writer.WriteAttributeString("Layer", layer); //write some simple elements writer.WriteElementString("Message", msg); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndElement(); writer.Close(); } catch (Exception ex) { throw ex; } }</pre> </div> </figure> </div> <div class="example-item" id="0x2c44602f28e45a54690b9119506fa9e3ff619cbe4130ce6880ff95b6c44328ca-105,,121,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #35</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_35" data-hash="0x2c44602f28e45a54690b9119506fa9e3ff619cbe4130ce6880ff95b6c44328ca" data-area="105,,121,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '35')" class="rating-up btn btn-success" data-id="rating_35"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'35')" class="rating-down btn btn-danger" data-id="rating_35"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x2c44602f28e45a54690b9119506fa9e3ff619cbe4130ce6880ff95b6c44328ca-105,,121,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x2c44602f28e45a54690b9119506fa9e3ff619cbe4130ce6880ff95b6c44328ca')">Show file</a> </div> <div class="example-project-info"> <nobr> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect"></a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="35"> <pre class="line-numbers language-csharp" data-end="121" data-start="106" data-highlight="112,114,116,118"> public void SaveV1PeakParameters(System.Xml.XmlTextWriter xwriter) { xwriter.WriteWhitespace("\n\t"); xwriter.WriteStartElement("PeakParameters"); xwriter.WriteWhitespace("\n\t\t"); xwriter.WriteElementString("PeakBackgroundRatio", System.Convert.ToString(this.PeakBackgroundRatio)); xwriter.WriteWhitespace("\n\t\t"); xwriter.WriteElementString("SignalToNoiseThreshold", this.SignalToNoiseThreshold.ToString()); xwriter.WriteWhitespace("\n\t\t"); xwriter.WriteElementString("PeakFitType", this.PeakFitType.ToString()); xwriter.WriteWhitespace("\n\t\t"); xwriter.WriteElementString("WritePeaksToTextFile", this.WritePeaksToTextFile.ToString()); xwriter.WriteWhitespace("\n\t"); xwriter.WriteEndElement(); }</pre> </div> </figure> </div> <div class="example-item" id="0xe952ac639708ebf075e23c88318820947178cbde2ddd02a226495491dfc58b23-340,,396,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #36</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_36" data-hash="0xe952ac639708ebf075e23c88318820947178cbde2ddd02a226495491dfc58b23" data-area="340,,396,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '36')" class="rating-up btn btn-success" data-id="rating_36"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'36')" class="rating-down btn btn-danger" data-id="rating_36"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xe952ac639708ebf075e23c88318820947178cbde2ddd02a226495491dfc58b23-340,,396,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xe952ac639708ebf075e23c88318820947178cbde2ddd02a226495491dfc58b23&fullName=wwt-windows-client-master%2FReferenceFrame.cs&project=philrosenfield%2Fwwt-windows-client')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fphilrosenfield%2Fwwt-windows-client%2Fblob%2Fmaster%2Fwwt-windows-client-master%2FReferenceFrame.cs">ReferenceFrame.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fphilrosenfield%2Fwwt-windows-client">philrosenfield/wwt-windows-client</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="36"> <pre class="line-numbers language-csharp" data-end="396" data-start="341" data-highlight="391"> public virtual void SaveToXml(System.Xml.XmlTextWriter xmlWriter) { xmlWriter.WriteStartElement("ReferenceFrame"); xmlWriter.WriteAttributeString("Name", Name); xmlWriter.WriteAttributeString("Parent", Parent); xmlWriter.WriteAttributeString("ReferenceFrameType", ReferenceFrameType.ToString()); xmlWriter.WriteAttributeString("Reference", Reference.ToString()); xmlWriter.WriteAttributeString("ParentsRoationalBase", ParentsRoationalBase.ToString()); xmlWriter.WriteAttributeString("MeanRadius", MeanRadius.ToString()); xmlWriter.WriteAttributeString("Oblateness", Oblateness.ToString()); xmlWriter.WriteAttributeString("Heading", Heading.ToString()); xmlWriter.WriteAttributeString("Pitch", Pitch.ToString()); xmlWriter.WriteAttributeString("Roll", Roll.ToString()); xmlWriter.WriteAttributeString("Scale", Scale.ToString()); xmlWriter.WriteAttributeString("Tilt", Tilt.ToString()); xmlWriter.WriteAttributeString("Translation", Translation.ToString()); if (ReferenceFrameType == ReferenceFrameTypes.FixedSherical) { xmlWriter.WriteAttributeString("Lat", Lat.ToString()); xmlWriter.WriteAttributeString("Lng", Lng.ToString()); xmlWriter.WriteAttributeString("Altitude", Altitude.ToString()); } xmlWriter.WriteAttributeString("RotationalPeriod", RotationalPeriod.ToString()); xmlWriter.WriteAttributeString("ZeroRotationDate", ZeroRotationDate.ToString()); xmlWriter.WriteAttributeString("RepresentativeColor", SavedColor.Save(RepresentativeColor)); xmlWriter.WriteAttributeString("ShowAsPoint", ShowAsPoint.ToString()); xmlWriter.WriteAttributeString("ShowOrbitPath", ShowOrbitPath.ToString()); xmlWriter.WriteAttributeString("StationKeeping", StationKeeping.ToString()); if (ReferenceFrameType == ReferenceFrameTypes.Orbital) { xmlWriter.WriteAttributeString("SemiMajorAxis", SemiMajorAxis.ToString()); xmlWriter.WriteAttributeString("SemiMajorAxisScale", this.SemiMajorAxisUnits.ToString()); xmlWriter.WriteAttributeString("Eccentricity", Eccentricity.ToString()); xmlWriter.WriteAttributeString("Inclination", Inclination.ToString()); xmlWriter.WriteAttributeString("ArgumentOfPeriapsis", ArgumentOfPeriapsis.ToString()); xmlWriter.WriteAttributeString("LongitudeOfAscendingNode", LongitudeOfAscendingNode.ToString()); xmlWriter.WriteAttributeString("MeanAnomolyAtEpoch", MeanAnomolyAtEpoch.ToString()); xmlWriter.WriteAttributeString("MeanDailyMotion", MeanDailyMotion.ToString()); xmlWriter.WriteAttributeString("Epoch", Epoch.ToString()); } if (ReferenceFrameType == ReferenceFrameTypes.Trajectory) { xmlWriter.WriteStartElement("Trajectory"); foreach (TrajectorySample sample in Trajectory) { string data = sample.ToString(); xmlWriter.WriteElementString("Sample", data); } xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); }</pre> </div> </figure> </div> <div class="example-item" id="0x9528ea87bbded28ca988428b3b28effc681e3e08d6f4625a4ddb70411e6c10d3-282,,300,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #37</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_37" data-hash="0x9528ea87bbded28ca988428b3b28effc681e3e08d6f4625a4ddb70411e6c10d3" data-area="282,,300,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '37')" class="rating-up btn btn-success" data-id="rating_37"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'37')" class="rating-down btn btn-danger" data-id="rating_37"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x9528ea87bbded28ca988428b3b28effc681e3e08d6f4625a4ddb70411e6c10d3-282,,300,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x9528ea87bbded28ca988428b3b28effc681e3e08d6f4625a4ddb70411e6c10d3')">Show file</a> </div> <div class="example-project-info"> <nobr> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect"></a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="37"> <pre class="line-numbers language-csharp" data-end="300" data-start="283" data-highlight="288,296"> public void Save(System.Xml.XmlTextWriter tw, string localName) { tw.WriteStartElement(localName); tw.WriteAttributeString("Version", "1"); tw.WriteElementString("DirectionRecentFirst", System.Xml.XmlConvert.ToString(_viewDirectionRecentIsFirst)); tw.WriteStartElement("ColumnWidths"); var colWidths = null != _view ? _view.ColumnWidths : new double[0]; tw.WriteAttributeString("Count", XmlConvert.ToString(colWidths.Length)); for (int i = 0; i < colWidths.Length; i++) { tw.WriteElementString("Width", XmlConvert.ToString(colWidths[i])); } tw.WriteEndElement(); // "ColumnWidths" tw.WriteEndElement(); // localName }</pre> </div> </figure> </div> <div class="example-item" id="0x3e2b6eed0d51eb0b962307e949ec2869a3cb1f59ac0f3f56566a00d81487285a-102,,125,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #38</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_38" data-hash="0x3e2b6eed0d51eb0b962307e949ec2869a3cb1f59ac0f3f56566a00d81487285a" data-area="102,,125,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '38')" class="rating-up btn btn-success" data-id="rating_38"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'38')" class="rating-down btn btn-danger" data-id="rating_38"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x3e2b6eed0d51eb0b962307e949ec2869a3cb1f59ac0f3f56566a00d81487285a-102,,125,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x3e2b6eed0d51eb0b962307e949ec2869a3cb1f59ac0f3f56566a00d81487285a')">Show file</a> </div> <div class="example-project-info"> <nobr> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect"></a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="38"> <pre class="line-numbers language-csharp" data-end="125" data-start="103" data-highlight="118,119"> ///<summary> /// SyggestSync is a goodies to ask a proper sync of what's /// present in RAM, and what's present in the XML file. ///</summary> public void SuggestSync() { XmlTextWriter writer = new System.Xml.XmlTextWriter("configuration.xml", null); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteStartElement("entries"); foreach (string key in m_Matches.Keys) { writer.WriteStartElement("entry"); writer.WriteElementString("key", key); writer.WriteElementString("value", (string)m_Matches[key]); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); writer.Close(); }</pre> </div> </figure> </div> <div class="example-item" id="0xb624b45a48b2c9284a62cb7f596693da7954b8e7eb8f8c997f5a43b7689906dd-45,,60,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #39</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_39" data-hash="0xb624b45a48b2c9284a62cb7f596693da7954b8e7eb8f8c997f5a43b7689906dd" data-area="45,,60,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '39')" class="rating-up btn btn-success" data-id="rating_39"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'39')" class="rating-down btn btn-danger" data-id="rating_39"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xb624b45a48b2c9284a62cb7f596693da7954b8e7eb8f8c997f5a43b7689906dd-45,,60,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xb624b45a48b2c9284a62cb7f596693da7954b8e7eb8f8c997f5a43b7689906dd')">Show file</a> </div> <div class="example-project-info"> <nobr> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect"></a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="39"> <pre class="line-numbers language-csharp" data-end="60" data-start="46" data-highlight="55"> public void WriteValue(string strSection, string strKey, string strValue) { //XmlNodeList mNode = mXml.GetElementsByTagName(strSection); XmlTextWriter mXmlWrite = new System.Xml.XmlTextWriter(this.strPathOfXml, System.Text.UTF8Encoding.UTF8); mXmlWrite.Formatting = Formatting.Indented; mXmlWrite.WriteStartDocument(); mXmlWrite.WriteStartElement("property"); mXmlWrite.WriteStartElement(strSection); mXmlWrite.WriteElementString(strKey, strValue); mXmlWrite.WriteEndElement(); mXmlWrite.WriteEndElement(); mXmlWrite.WriteEndDocument(); mXmlWrite.Flush(); mXmlWrite.Close(); }</pre> </div> </figure> </div> <div class="example-item" id="0xcc1a4ded89fa0f1441b9c23ff849c6d4f62e1c34e196cb769511bd9a530b090f-487,,508,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #40</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_40" data-hash="0xcc1a4ded89fa0f1441b9c23ff849c6d4f62e1c34e196cb769511bd9a530b090f" data-area="487,,508,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '40')" class="rating-up btn btn-success" data-id="rating_40"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'40')" class="rating-down btn btn-danger" data-id="rating_40"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xcc1a4ded89fa0f1441b9c23ff849c6d4f62e1c34e196cb769511bd9a530b090f-487,,508,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xcc1a4ded89fa0f1441b9c23ff849c6d4f62e1c34e196cb769511bd9a530b090f')">Show file</a> </div> <div class="example-project-info"> <nobr> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect"></a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="40"> <pre class="line-numbers language-csharp" data-end="508" data-start="488" data-highlight="497"> /// <summary> /// Writes the XML element. /// </summary> /// <param name="writer">The writer.</param> virtual protected void WriteXMLElement(System.Xml.XmlTextWriter writer) { writer.WriteAttributeString("type", this.ResourceType.Name); writer.WriteAttributeString("name", _name); writer.WriteAttributeString("id", ID.ToString()); writer.WriteElementString("family", (Parent != null) ? Parent.QualifiedName : ""); foreach (FieldValueList fieldValues in this.Fields.Values) { foreach (object v in fieldValues.Values) { writer.WriteStartElement("field"); writer.WriteAttributeString("name", fieldValues.Type.Name); writer.WriteValue(v.ToString()); writer.WriteEndElement(); } } }</pre> </div> </figure> </div> <div class="example-item" id="0x6d3ef6b4f24ddfe26dceb556c2c49f7d7a0237f3d9e1ed459dde89af8455b1d0-468,,552,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #41</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_41" data-hash="0x6d3ef6b4f24ddfe26dceb556c2c49f7d7a0237f3d9e1ed459dde89af8455b1d0" data-area="468,,552,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '41')" class="rating-up btn btn-success" data-id="rating_41"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'41')" class="rating-down btn btn-danger" data-id="rating_41"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x6d3ef6b4f24ddfe26dceb556c2c49f7d7a0237f3d9e1ed459dde89af8455b1d0-468,,552,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x6d3ef6b4f24ddfe26dceb556c2c49f7d7a0237f3d9e1ed459dde89af8455b1d0')">Show file</a> </div> <div class="example-project-info"> <nobr> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect"></a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="41"> <pre class="line-numbers language-csharp" data-end="552" data-start="469" data-highlight="492,493,496,501,513,518,523,532,537,542,545"> private void SaveXmlCommandFile(string filename) { if (this.MergeListFileArray.Count < 1) { return; } System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(filename, new System.Text.UnicodeEncoding()); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteStartElement("merge"); // Write sub-elements foreach (MergeListFiles mergeItem in this.MergeListFileArray) { writer.WriteStartElement("file"); if (mergeItem.Include == false) { writer.WriteAttributeString("exclude", "1"); } writer.WriteElementString("path", mergeItem.Path); writer.WriteElementString("pages", mergeItem.Pages); if (mergeItem.Bookmark != null) { writer.WriteElementString("bookmark", mergeItem.Bookmark); } if (mergeItem.Level > 0) { writer.WriteElementString("level", XmlConvert.ToString(mergeItem.Level)); } writer.WriteEndElement(); } #region write info and options if (this.MergeListInfo.HasInfo == true) { writer.WriteStartElement("info"); if (this.MergeListInfo.InfoAuthor.Length > 0) { writer.WriteElementString("author", this.MergeListInfo.InfoAuthor); } if (this.MergeListInfo.InfoSubject.Length > 0) { writer.WriteElementString("subject", this.MergeListInfo.InfoSubject); } if (this.MergeListInfo.InfoTitle.Length > 0) { writer.WriteElementString("title", this.MergeListInfo.InfoTitle); } writer.WriteEndElement(); } writer.WriteStartElement("options"); if (string.IsNullOrEmpty(this.MergeListInfo.OutFilename) == false) { writer.WriteElementString("outfile", this.MergeListInfo.OutFilename); } if (string.IsNullOrEmpty(this.MergeListInfo.Annotation) == false) { writer.WriteElementString("annotation", this.MergeListInfo.Annotation); } if (this.MergeListInfo.NumberPages == true) { writer.WriteElementString("startpage", this.MergeListInfo.StartPage.ToString()); } writer.WriteElementString("paginationformat", ((int)this.MergeListInfo.PaginationFormat).ToString()); writer.WriteEndElement(); #endregion writer.WriteFullEndElement(); writer.Close(); }</pre> </div> </figure> </div> <div class="example-item" id="0x75640425f9738c44b34ef1ba4ef568cc3bb70d42aa2357389cd756bbe35dc852-6,,69,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #42</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_42" data-hash="0x75640425f9738c44b34ef1ba4ef568cc3bb70d42aa2357389cd756bbe35dc852" data-area="6,,69,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '42')" class="rating-up btn btn-success" data-id="rating_42"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'42')" class="rating-down btn btn-danger" data-id="rating_42"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0x75640425f9738c44b34ef1ba4ef568cc3bb70d42aa2357389cd756bbe35dc852-6,,69,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0x75640425f9738c44b34ef1ba4ef568cc3bb70d42aa2357389cd756bbe35dc852&fullName=maximizing-.net-perf-master%2FTestHarness%2FFileOutput.cs&project=coderisrael%2Fmaximizing-.net-perf')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fcoderisrael%2Fmaximizing-.net-perf%2Fblob%2Fmaster%2Fmaximizing-.net-perf-master%2FTestHarness%2FFileOutput.cs">FileOutput.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fcoderisrael%2Fmaximizing-.net-perf">coderisrael/maximizing-.net-perf</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="42"> <pre class="line-numbers language-csharp" data-end="69" data-start="7" data-highlight="63"> protected override void OutputResults(TestResultGrp resultGrp, object[] ConfigSettings) { TestResult[] Results = resultGrp.Results; string procName = ""; uint L2CacheSize = 0; uint L2CacheSpeed = 0; int procNo = 0; ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT Name, L2CacheSize, L2CacheSpeed FROM Win32_Processor"); ManagementObjectCollection moc = mos.Get(); foreach (ManagementObject mob in moc) { ++procNo; procName = mob.Properties["Name"].Value.ToString(); L2CacheSize = Convert.ToUInt32(mob.Properties["L2CacheSize"].Value); L2CacheSpeed = Convert.ToUInt32(mob.Properties["L2CacheSpeed"].Value); } if (Results == null) { return; } string xmlFileName = (string)ConfigSettings[0]; if (xmlFileName == String.Empty) { xmlFileName = "c:\\" + resultGrp.TestName + ".xml"; } System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(xmlFileName, System.Text.Encoding.UTF8); writer.WriteStartElement("testresults"); writer.WriteAttributeString("Name", resultGrp.TestName); if (resultGrp.Motivation != String.Empty) { writer.WriteAttributeString("Motivation", resultGrp.Motivation); } writer.WriteAttributeString("TestTime", DateTime.UtcNow.ToString("r")); writer.WriteAttributeString("MachineName", System.Environment.MachineName); writer.WriteAttributeString("CLR_Version", System.Environment.Version.ToString()); writer.WriteAttributeString("OS", System.Environment.OSVersion.ToString()); writer.WriteAttributeString("NoProcessors", procNo.ToString()); writer.WriteAttributeString("ProcName", procName); writer.WriteAttributeString("L2CacheSize_Kilobytes", L2CacheSize.ToString()); writer.WriteAttributeString("L2CacheSpeed_MegaHertz", L2CacheSpeed.ToString()); foreach (DotNetPerformance.TestResult tr in Results) { writer.WriteStartElement("testresult"); writer.WriteAttributeString("Name", tr.TestName); writer.WriteAttributeString("Min", tr.Min.TotalMilliseconds.ToString()); writer.WriteAttributeString("Median", tr.Median.TotalMilliseconds.ToString()); writer.WriteAttributeString("Max", tr.Max.TotalMilliseconds.ToString()); writer.WriteAttributeString("NormalizedTestDuration", tr.NormalizedTestDuration.ToString()); foreach (TimeSpan ts in tr.TestResults) { writer.WriteElementString("testrun", ts.TotalMilliseconds.ToString()); } writer.WriteEndElement(); } writer.WriteEndElement(); writer.Close(); System.Diagnostics.Process.Start(xmlFileName); }</pre> </div> </figure> </div> <div class="example-item" id="0xa049bd7255cfed304f0039a774d1163fbe0391f2479606e67c88aaa82717807d-92,,263,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #43</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_43" data-hash="0xa049bd7255cfed304f0039a774d1163fbe0391f2479606e67c88aaa82717807d" data-area="92,,263,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '43')" class="rating-up btn btn-success" data-id="rating_43"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'43')" class="rating-down btn btn-danger" data-id="rating_43"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xa049bd7255cfed304f0039a774d1163fbe0391f2479606e67c88aaa82717807d-92,,263,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xa049bd7255cfed304f0039a774d1163fbe0391f2479606e67c88aaa82717807d&fullName=WEBAPI-master%2FWebAPI%2FFacturaElectronicaCR.cs&project=wjimenezrcr%2FWEBAPI')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fwjimenezrcr%2FWEBAPI%2Fblob%2Fmaster%2FWEBAPI-master%2FWebAPI%2FFacturaElectronicaCR.cs">FacturaElectronicaCR.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fwjimenezrcr%2FWEBAPI">wjimenezrcr/WEBAPI</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="43"> <pre class="line-numbers language-csharp" data-end="263" data-start="93" data-highlight="106,110,113,117,119,120,127,128,129,130,131,135,136,139,146,149,150,154,155,158,164,174,176,233,234,235,236,238,239,241,242,243,244,245,250,251"> private void GeneraXML(System.Xml.XmlTextWriter writer) // As System.Xml.XmlTextWriter { try { writer.WriteStartDocument(); writer.WriteStartElement("FacturaElectronica"); writer.WriteAttributeString("xmlns", "https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/facturaElectronica"); writer.WriteAttributeString("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#"); writer.WriteAttributeString("xmlns:vc", "http://www.w3.org/2007/XMLSchema-versioning"); writer.WriteAttributeString("xmlns:xs", "http://www.w3.org/2001/XMLSchema"); // La clave se crea con la función CreaClave de la clase Datos writer.WriteElementString("Clave", _numeroClave); // 'El numero de secuencia es de 20 caracteres, // 'Se debe de crear con la función CreaNumeroSecuencia de la clase Datos writer.WriteElementString("NumeroConsecutivo", _numeroConsecutivo); // 'El formato de la fecha es yyyy-MM-ddTHH:mm:sszzz writer.WriteElementString("FechaEmision", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz")); writer.WriteStartElement("Emisor"); writer.WriteElementString("Nombre", _emisor.Nombre); writer.WriteStartElement("Identificacion"); writer.WriteElementString("Tipo", _emisor.Tipo_Identificacion); writer.WriteElementString("Numero", _emisor.Numero_Identificacion); writer.WriteEndElement(); // 'Identificacion // '----------------------------------- // 'Los datos de las ubicaciones los puede tomar de las tablas de datos, // 'Debe ser exacto al que hacienda tiene registrado para su compañia writer.WriteStartElement("Ubicacion"); writer.WriteElementString("Provincia", _emisor.Provincia); writer.WriteElementString("Canton", _emisor.Canton); writer.WriteElementString("Distrito", _emisor.Distrito); writer.WriteElementString("Barrio", _emisor.Barrio); writer.WriteElementString("OtrasSenas", _emisor.OtrasSenas); writer.WriteEndElement(); // 'Ubicacion writer.WriteStartElement("Telefono"); writer.WriteElementString("CodigoPais", _emisor.CodigoPaisTel); writer.WriteElementString("NumTelefono", _emisor.NumTelefono.ToString()); writer.WriteEndElement(); // 'Telefono writer.WriteElementString("CorreoElectronico", _emisor.CorreoElectronico); writer.WriteEndElement(); // Emisor // '------------------------------------ // 'Receptor es similar con emisor, los datos opcionales siempre siempre siempre omitirlos. // 'La ubicacion para el receptor es opcional por ejemplo writer.WriteStartElement("Receptor"); writer.WriteElementString("Nombre", _receptor.Nombre); writer.WriteStartElement("Identificacion"); // 'Los tipos de identificacion los puede ver en la tabla de datos writer.WriteElementString("Tipo", _receptor.Tipo_Identificacion); writer.WriteElementString("Numero", _receptor.Numero_Identificacion); writer.WriteEndElement(); // 'Identificacion writer.WriteStartElement("Telefono"); writer.WriteElementString("CodigoPais", _receptor.CodigoPaisTel); writer.WriteElementString("NumTelefono", _receptor.NumTelefono.ToString()); writer.WriteEndElement(); // 'Telefono writer.WriteElementString("CorreoElectronico", _receptor.CorreoElectronico); writer.WriteEndElement(); // Receptor // '------------------------------------ // 'Loa datos estan en la tabla correspondiente writer.WriteElementString("CondicionVenta", _condicionVenta); // '01: Contado // '02: Credito // '03: Consignación // '04: Apartado // '05: Arrendamiento con opcion de compra // '06: Arrendamiento con función financiera // '99: Otros // 'Este dato se muestra si la condicion venta es credito writer.WriteElementString("PlazoCredito", _plazoCredito); writer.WriteElementString("MedioPago", _medioPago); // '01: Efectivo // '02: Tarjeta // '03: Cheque // '04: Transferecia - deposito bancario // '05: Recaudado por terceros // '99: Otros writer.WriteStartElement("DetalleServicio"); // '------------------------------------- /* foreach (DataRow dr in _dsDetalle.Tables["detalle"].Rows) * { * writer.WriteStartElement("LineaDetalle"); * * writer.WriteElementString("NumeropLinea", dr["numero_linea"].ToString()); * * writer.WriteStartElement("Codigo"); * writer.WriteElementString("Tipo", dr["articulo_tipo"].ToString()); * writer.WriteElementString("Codigo", dr["articulo_codigo"].ToString()); * writer.WriteEndElement(); // 'Codigo * * writer.WriteElementString("Cantidad", dr["cantidad"].ToString()); * // 'Para las unidades de medida ver la tabla correspondiente * writer.WriteElementString("UnidadMedida", dr["unidad_medida"].ToString()); * writer.WriteElementString("Detalle", dr["detalle_articulo"].ToString()); * writer.WriteElementString("PrecioUnitario", String.Format("{0:N3}", dr["precio_unitario"].ToString())); * writer.WriteElementString("MontoTotal", String.Format("{0:N3}", dr["monto_total"].ToString())); * writer.WriteElementString("MontoDescuento", String.Format("{0:N3}", dr["nonto_descuento"].ToString())); * writer.WriteElementString("NaturalezaDescuento", dr["naturaleza_descuento"].ToString()); * writer.WriteElementString("SubTotal", String.Format("{0:N3}", dr["sub_total"].ToString())); * * writer.WriteStartElement("Impuesto"); * writer.WriteElementString("Codigo", dr["impuesto_codigo"].ToString()); * writer.WriteElementString("Tarifa", dr["impuesto_tarifa"].ToString()); * writer.WriteElementString("Monto", dr["impuesto_monto"].ToString()); * writer.WriteEndElement(); // Impuesto * * writer.WriteElementString("MontoTotalLinea", String.Format("{0:N3}", dr["monto_linea"].ToString())); * * writer.WriteEndElement(); // LineaDetalle * } * // '------------------------------------- * * writer.WriteEndElement(); // DetalleServicio*/ writer.WriteStartElement("ResumenFactura"); // Estos campos son opcionales, solo fin desea facturar en dólares //writer.WriteElementString("CodigoMoneda", _codigoMoneda); // writer.WriteElementString("TipoCambio", "aqui_tipo_cambio"); // ================= // 'En esta parte los totales se pueden ir sumando linea a linea cuando se carga el detalle // 'ó se pasa como parametros al inicio writer.WriteElementString("TotalServGravados", ""); writer.WriteElementString("TotalServExentos", ""); writer.WriteElementString("TotalMercanciasGravadas", ""); writer.WriteElementString("TotalMercanciasExentas", ""); writer.WriteElementString("TotalGravado", ""); writer.WriteElementString("TotalExento", ""); writer.WriteElementString("TotalVenta", ""); writer.WriteElementString("TotalDescuentos", ""); writer.WriteElementString("TotalVentaNeta", ""); writer.WriteElementString("TotalImpuesto", ""); writer.WriteElementString("TotalComprobante", ""); writer.WriteEndElement(); // ResumenFactura // 'Estos datos te los tiene que brindar los encargados del area financiera writer.WriteStartElement("Normativa"); writer.WriteElementString("NumeroResolucion", ""); writer.WriteElementString("FechaResolucion", ""); writer.WriteEndElement(); // Normativa // 'Aqui va la firma, despues la agregamos. writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); } catch (Exception ex) { throw ex; } }</pre> </div> </figure> </div> <div class="example-item" id="0xe673860cc09c783dadd3f7c742235690cf10e57e04883e279adb1c7282cc665e-688,,775,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #44</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_44" data-hash="0xe673860cc09c783dadd3f7c742235690cf10e57e04883e279adb1c7282cc665e" data-area="688,,775,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '44')" class="rating-up btn btn-success" data-id="rating_44"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'44')" class="rating-down btn btn-danger" data-id="rating_44"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xe673860cc09c783dadd3f7c742235690cf10e57e04883e279adb1c7282cc665e-688,,775,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xe673860cc09c783dadd3f7c742235690cf10e57e04883e279adb1c7282cc665e')">Show file</a> </div> <div class="example-project-info"> <nobr> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect"></a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="44"> <pre class="line-numbers language-csharp" data-end="775" data-start="689" data-highlight="763,764,765"> private void Write_XML() { XmlTextWriter XmlWtr = new System.Xml.XmlTextWriter("..\\..\\..\\xml\\lh_giostt.xml", null); //XmlFile XmlWtr.Formatting = Formatting.Indented; XmlWtr.WriteStartDocument(); XmlWtr.WriteStartElement("Import"); h_start = int.Parse(cmbgbd.Text.Substring(0, 2)); m_start = int.Parse(cmbpbd.Text.Substring(0, 2)); h_end = int.Parse(cmbgkt.Text.Substring(0, 2)); m_end = int.Parse(cmbpkt.Text.Substring(0, 2)); int khoangcachthoigian; if (rdob10.Checked) { khoangcachthoigian = 10; } else { if (rdob5.Checked) { khoangcachthoigian = 5; } else { khoangcachthoigian = 7; } } for (hours = h_start; hours <= h_end; hours++) { counts++; if (counts == 1) { //pbd=int.Parse(cmbpbd.Text.Substring(0,2)); m_start = int.Parse("00"); //pkt=55; m_end = 59; } else { m_start = 0; //pkt=55; m_end = 59; } if ((counts + h_start) == (h_end + 1)) { m_start = 0; //pkt=int.Parse(cmbpkt.Text.Substring(0,2)); m_end = int.Parse("30"); } for (minutes = m_start; minutes <= m_end; minutes = minutes + 1) { lan++; if (hours.ToString().Length == 1) { wss = "0" + hours.ToString(); } else { wss = hours.ToString(); } if (minutes.ToString().Length == 1) { qss = "0" + minutes.ToString(); } else { qss = minutes.ToString(); } ass = wss + ":" + qss; XmlWtr.WriteStartElement("Giolam"); XmlWtr.WriteElementString("Gio", ass); XmlWtr.WriteElementString("Sothutu", stt.ToString()); XmlWtr.WriteElementString("Thoigiantb", khoangcachthoigian.ToString()); if (lan == khoangcachthoigian) { stt++; lan = 0; } XmlWtr.WriteEndElement(); } } XmlWtr.Flush(); XmlWtr.Close(); }</pre> </div> </figure> </div> <div class="example-item" id="0xe673860cc09c783dadd3f7c742235690cf10e57e04883e279adb1c7282cc665e-615,,686,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #45</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_45" data-hash="0xe673860cc09c783dadd3f7c742235690cf10e57e04883e279adb1c7282cc665e" data-area="615,,686,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '45')" class="rating-up btn btn-success" data-id="rating_45"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'45')" class="rating-down btn btn-danger" data-id="rating_45"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xe673860cc09c783dadd3f7c742235690cf10e57e04883e279adb1c7282cc665e-615,,686,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xe673860cc09c783dadd3f7c742235690cf10e57e04883e279adb1c7282cc665e')">Show file</a> </div> <div class="example-project-info"> <nobr> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect"></a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="45"> <pre class="line-numbers language-csharp" data-end="686" data-start="616" data-highlight="681"> private void WriteXML() { // string XmlFile; // System.IO.DirectoryInfo directoryInfo; // System.IO.DirectoryInfo directoryXML; // directoryInfo = System.IO.Directory.GetParent(Application.StartupPath); // if (directoryInfo.Name.ToString() == "bin") // { // directoryXML = System.IO.Directory.GetParent(directoryInfo.FullName); // XmlFile = directoryXML.FullName + "\\" + "gio.xml"; // } // else // XmlFile = directoryInfo.FullName + "\\" + "gio.xml"; XmlTextWriter XmlWtr = new System.Xml.XmlTextWriter("..\\..\\..\\xml\\lh_gio.xml", null); //XmlFile XmlWtr.Formatting = Formatting.Indented; XmlWtr.WriteStartDocument(); XmlWtr.WriteStartElement("Import"); gbd = int.Parse(cmbgbd.Text.Substring(0, 2)); pbd = int.Parse(cmbpbd.Text.Substring(0, 2)); gkt = int.Parse(cmbgkt.Text.Substring(0, 2)); pkt = int.Parse(cmbpkt.Text.Substring(0, 2)); for (gio = gbd; gio <= gkt; gio++) { count++; if (count == 1) { pbd = int.Parse(cmbpbd.Text.Substring(0, 2)); pkt = 55; } else { pbd = 0; pkt = 55; } if ((count + gbd) == (gkt + 1)) { pbd = 0; pkt = int.Parse(cmbpkt.Text.Substring(0, 2)); } for (phut = pbd; phut <= pkt; phut = phut + 5) { if (gio.ToString().Length == 1) { w = "0" + gio.ToString(); } else { w = gio.ToString(); } if (phut.ToString().Length == 1) { q = "0" + phut.ToString(); } else { q = phut.ToString(); } a = w + ":" + q; //cmb.Items.Add(a); XmlWtr.WriteStartElement("Giolam"); XmlWtr.WriteElementString("Gio", a); XmlWtr.WriteEndElement(); } } XmlWtr.Flush(); XmlWtr.Close(); }</pre> </div> </figure> </div> <div class="example-item" id="0xde40bff8b407d365a7ee6da5b025ba2949c8b3893acd6ce89a63f13e01637353-31,,97,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #46</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_46" data-hash="0xde40bff8b407d365a7ee6da5b025ba2949c8b3893acd6ce89a63f13e01637353" data-area="31,,97,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '46')" class="rating-up btn btn-success" data-id="rating_46"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'46')" class="rating-down btn btn-danger" data-id="rating_46"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xde40bff8b407d365a7ee6da5b025ba2949c8b3893acd6ce89a63f13e01637353-31,,97,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xde40bff8b407d365a7ee6da5b025ba2949c8b3893acd6ce89a63f13e01637353')">Show file</a> </div> <div class="example-project-info"> <nobr> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect"></a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="46"> <pre class="line-numbers language-csharp" data-end="97" data-start="32" data-highlight="53,55,57,58,60,61,62,89,90,91"> public static void writeGPX(string filename, List <CurrentState> flightdata) { System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter( Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(filename) + ".gpx", Encoding.ASCII); xw.WriteStartElement("gpx"); xw.WriteAttributeString("creator", MainV2.instance.Text); xw.WriteAttributeString("xmlns", "http://www.topografix.com/GPX/1/1"); xw.WriteStartElement("trk"); xw.WriteStartElement("trkseg"); foreach (CurrentState cs in flightdata) { xw.WriteStartElement("trkpt"); xw.WriteAttributeString("lat", cs.lat.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteAttributeString("lon", cs.lng.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("ele", cs.altasl.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("ele2", cs.alt.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("time", cs.datetime.ToString("yyyy-MM-ddTHH:mm:sszzzzzz")); xw.WriteElementString("course", (cs.yaw).ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("roll", cs.roll.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("pitch", cs.pitch.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("mode", cs.mode.ToString(new System.Globalization.CultureInfo("en-US"))); //xw.WriteElementString("speed", mod.model.Orientation.); //xw.WriteElementString("fix", cs.altitude); xw.WriteEndElement(); } xw.WriteEndElement(); xw.WriteEndElement(); int a = 0; DateTime lastsample = DateTime.MinValue; foreach (CurrentState cs in flightdata) { if (cs.datetime.Second != lastsample.Second) { lastsample = cs.datetime; } else { //continue; } xw.WriteStartElement("wpt"); xw.WriteAttributeString("lat", cs.lat.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteAttributeString("lon", cs.lng.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteElementString("name", (a++).ToString()); xw.WriteElementString("time", cs.datetime.ToString("yyyy-MM-ddTHH:mm:sszzzzzz")); xw.WriteElementString("ele", cs.altasl.ToString(new System.Globalization.CultureInfo("en-US"))); xw.WriteEndElement(); //wpt } xw.WriteEndElement(); xw.Close(); }</pre> </div> </figure> </div> <div class="example-item" id="0xaab9a43221a1bc0e38ad4682c8e5ca144a944c0018e1b2524542cfab852ed91f-116,,187,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #47</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_47" data-hash="0xaab9a43221a1bc0e38ad4682c8e5ca144a944c0018e1b2524542cfab852ed91f" data-area="116,,187,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '47')" class="rating-up btn btn-success" data-id="rating_47"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'47')" class="rating-down btn btn-danger" data-id="rating_47"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xaab9a43221a1bc0e38ad4682c8e5ca144a944c0018e1b2524542cfab852ed91f-116,,187,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xaab9a43221a1bc0e38ad4682c8e5ca144a944c0018e1b2524542cfab852ed91f')">Show file</a> </div> <div class="example-project-info"> <nobr> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect"></a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="47"> <pre class="line-numbers language-csharp" data-end="187" data-start="117" data-highlight="162,163,170,171"> private void WriteFile_Click(object sender, System.EventArgs e) { string XmlFile; System.IO.DirectoryInfo directoryInfo; System.IO.DirectoryInfo directoryXML; //Get the applications startup path directoryInfo = System.IO.Directory.GetParent(Application.StartupPath); //Set the output path if (directoryInfo.Name.ToString() == "bin") { directoryXML = System.IO.Directory.GetParent(directoryInfo.FullName); XmlFile = directoryXML.FullName + "\\" + OutputFileName.Text; } else { XmlFile = directoryInfo.FullName + "\\" + OutputFileName.Text; } //create the xml text writer object by providing the filename to write to //and the desired encoding. If the encoding is left null, then the writer //assumes UTF-8. XmlTextWriter XmlWtr = new System.Xml.XmlTextWriter(XmlFile, null); //set the formatting option of the xml file. The default indentation is 2 character spaces. //To change the default, use the Indentation property to set the number of IndentChars to use //and use the IndentChar property to set the character to use for indentation, such as the //tab character. Here the default is used. XmlWtr.Formatting = Formatting.Indented; //begin to write the xml document. This creates the xml declaration with the version attribute //set to "1.0". XmlWtr.WriteStartDocument(); //start the first element. XmlWtr.WriteStartElement("customers"); //create our first customer element. //this is a child element of the customers element. XmlWtr.WriteStartElement("customer"); //writes the entire element with the specified element name and //string value respectively. XmlWtr.WriteElementString("name", "Kevin Anders"); XmlWtr.WriteElementString("phone", "555.555.5555"); //end the customer element. XmlWtr.WriteEndElement(); //create another customer. XmlWtr.WriteStartElement("customer"); XmlWtr.WriteElementString("name", "Staci Richard"); XmlWtr.WriteElementString("phone", "555.122.1552"); //end the second customer element. XmlWtr.WriteEndElement(); //end the customers element. XmlWtr.WriteEndElement(); //now end the document. XmlWtr.WriteEndDocument(); //now flush the contents of the stream. XmlWtr.Flush(); //close the text writerj and write the xml file. XmlWtr.Close(); statusBar1.Text = "Output file has been written"; }</pre> </div> </figure> </div> <div class="example-item" id="0xc5e3353126d8a59106bd67ccf2d86539ff8f3cc3d35d7c6e93910388046a61e4-91,,281,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #48</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_48" data-hash="0xc5e3353126d8a59106bd67ccf2d86539ff8f3cc3d35d7c6e93910388046a61e4" data-area="91,,281,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '48')" class="rating-up btn btn-success" data-id="rating_48"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'48')" class="rating-down btn btn-danger" data-id="rating_48"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xc5e3353126d8a59106bd67ccf2d86539ff8f3cc3d35d7c6e93910388046a61e4-91,,281,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xc5e3353126d8a59106bd67ccf2d86539ff8f3cc3d35d7c6e93910388046a61e4&fullName=BajoRojo-master%2FFacturaElectronicaCR-master%2FFacturaElectronicaCR_CS%2FFacturaElectronicaCR.cs&project=johanRojas7%2FBajoRojo')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FjohanRojas7%2FBajoRojo%2Fblob%2Fmaster%2FBajoRojo-master%2FFacturaElectronicaCR-master%2FFacturaElectronicaCR_CS%2FFacturaElectronicaCR.cs">FacturaElectronicaCR.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FjohanRojas7%2FBajoRojo">johanRojas7/BajoRojo</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="48"> <pre class="line-numbers language-csharp" data-end="281" data-start="92" data-highlight="105,109,112,116,118,119,126,127,128,129,130,134,135,138,145,148,149,153,154,157,163,173,175,190,194,195,198,200,201,202,203,204,205,206,209,210,211,214,226,227,249,250,253,254,256,257,259,260,261,262,263,268,269"> private void GeneraXML(System.Xml.XmlTextWriter writer) // As System.Xml.XmlTextWriter { try { writer.WriteStartDocument(); writer.WriteStartElement("FacturaElectronica"); writer.WriteAttributeString("xmlns", "https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/facturaElectronica"); writer.WriteAttributeString("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#"); writer.WriteAttributeString("xmlns:vc", "http://www.w3.org/2007/XMLSchema-versioning"); writer.WriteAttributeString("xmlns:xs", "http://www.w3.org/2001/XMLSchema"); // La clave se crea con la función CreaClave de la clase Datos writer.WriteElementString("Clave", _numeroClave); // 'El numero de secuencia es de 20 caracteres, // 'Se debe de crear con la función CreaNumeroSecuencia de la clase Datos writer.WriteElementString("NumeroConsecutivo", _numeroConsecutivo); // 'El formato de la fecha es yyyy-MM-ddTHH:mm:sszzz writer.WriteElementString("FechaEmision", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz")); writer.WriteStartElement("Emisor"); writer.WriteElementString("Nombre", _emisor.Nombre); writer.WriteStartElement("Identificacion"); writer.WriteElementString("Tipo", _emisor.Identificacion_Tipo); writer.WriteElementString("Numero", _emisor.Identificacion_Numero); writer.WriteEndElement(); // 'Identificacion // '----------------------------------- // 'Los datos de las ubicaciones los puede tomar de las tablas de datos, // 'Debe ser exacto al que hacienda tiene registrado para su compañia writer.WriteStartElement("Ubicacion"); writer.WriteElementString("Provincia", _emisor.Ubicacion_Provincia); writer.WriteElementString("Canton", _emisor.Ubicacion_Canton); writer.WriteElementString("Distrito", _emisor.Ubicacion_Distrito); writer.WriteElementString("Barrio", _emisor.Ubicacion_Barrio); writer.WriteElementString("OtrasSenas", _emisor.Ubicacion_OtrasSenas); writer.WriteEndElement(); // 'Ubicacion writer.WriteStartElement("Telefono"); writer.WriteElementString("CodigoPais", _emisor.Telefono_CodigoPais); writer.WriteElementString("NumTelefono", _emisor.Telefono_Numero.ToString()); writer.WriteEndElement(); // 'Telefono writer.WriteElementString("CorreoElectronico", _emisor.CorreoElectronico); writer.WriteEndElement(); // Emisor // '------------------------------------ // 'Receptor es similar con emisor, los datos opcionales siempre siempre siempre omitirlos. // 'La ubicacion para el receptor es opcional por ejemplo writer.WriteStartElement("Receptor"); writer.WriteElementString("Nombre", _receptor.Nombre); writer.WriteStartElement("Identificacion"); // 'Los tipos de identificacion los puede ver en la tabla de datos writer.WriteElementString("Tipo", _receptor.Identificacion_Tipo); writer.WriteElementString("Numero", _receptor.Identificacion_Numero); writer.WriteEndElement(); // 'Identificacion writer.WriteStartElement("Telefono"); writer.WriteElementString("CodigoPais", _receptor.Telefono_CodigoPais); writer.WriteElementString("NumTelefono", _receptor.Telefono_Numero.ToString()); writer.WriteEndElement(); // 'Telefono writer.WriteElementString("CorreoElectronico", _receptor.CorreoElectronico); writer.WriteEndElement(); // Receptor // '------------------------------------ // 'Loa datos estan en la tabla correspondiente writer.WriteElementString("CondicionVenta", _condicionVenta); // '01: Contado // '02: Credito // '03: Consignación // '04: Apartado // '05: Arrendamiento con opcion de compra // '06: Arrendamiento con función financiera // '99: Otros // 'Este dato se muestra si la condicion venta es credito writer.WriteElementString("PlazoCredito", _plazoCredito); writer.WriteElementString("MedioPago", _medioPago); // '01: Efectivo // '02: Tarjeta // '03: Cheque // '04: Transferecia - deposito bancario // '05: Recaudado por terceros // '99: Otros writer.WriteStartElement("DetalleServicio"); // '------------------------------------- foreach (var xt in _dsDetalle) { writer.WriteStartElement("LineaDetalle"); writer.WriteElementString("NumeroLinea", xt.numeroDeLinea.ToString()); writer.WriteStartElement("Codigo"); writer.WriteElementString("Tipo", xt.tipoDeArticulo.ToString()); writer.WriteElementString("Codigo", xt.codigoArticulo.ToString()); writer.WriteEndElement(); // 'Codigo writer.WriteElementString("Cantidad", xt.cantidad.ToString()); // 'Para las unidades de medida ver la tabla correspondiente writer.WriteElementString("UnidadMedida", xt.unidadDeMedida.ToString()); writer.WriteElementString("Detalle", xt.detalle.ToString()); writer.WriteElementString("PrecioUnitario", String.Format("{0:N3}", xt.precioUnitario.ToString())); writer.WriteElementString("MontoTotal", String.Format("{0:N3}", xt.montoTotal.ToString())); writer.WriteElementString("MontoDescuento", String.Format("{0:N3}", xt.montoDescuento.ToString())); writer.WriteElementString("NaturalezaDescuento", xt.NaturalezaDescuento.ToString()); writer.WriteElementString("SubTotal", String.Format("{0:N3}", xt.subtotal.ToString())); writer.WriteStartElement("Impuesto"); writer.WriteElementString("Codigo", xt.codigoImpuesto.ToString()); writer.WriteElementString("Tarifa", xt.impuestoTarifa.ToString()); writer.WriteElementString("Monto", xt.impuestoMonto.ToString()); writer.WriteEndElement(); // Impuesto writer.WriteElementString("MontoTotalLinea", String.Format("{0:N3}", xt.montoTotalLinea.ToString())); writer.WriteEndElement(); // LineaDetalle } // '------------------------------------- writer.WriteEndElement(); // DetalleServicio writer.WriteStartElement("ResumenFactura"); // Estos campos son opcionales, solo fin desea facturar en dólares writer.WriteElementString("CodigoMoneda", _codigoMoneda); writer.WriteElementString("TipoCambio", "1.00000"); // ================= //SACAR CALCULOS PARA FACTURA double totalComprobante = 0; double montoTotalImpuesto = 0; foreach (var y in _dsDetalle) { montoTotalImpuesto = montoTotalImpuesto + y.impuestoMonto; } totalComprobante = 0 + montoTotalImpuesto; // 'En esta parte los totales se pueden ir sumando linea a linea cuando se carga el detalle // 'ó se pasa como parametros al inicio writer.WriteElementString("TotalServGravados", "0.00000"); writer.WriteElementString("TotalServExentos", "0.00000"); writer.WriteElementString("TotalMercanciasGravadas", "0.00000"); writer.WriteElementString("TotalMercanciasExentas", "0.00000"); writer.WriteElementString("TotalGravado", "0.00000"); writer.WriteElementString("TotalExento", "0.00000"); writer.WriteElementString("TotalVenta", "0.00000"); writer.WriteElementString("TotalDescuentos", "0.00000"); writer.WriteElementString("TotalVentaNeta", "0.00000"); writer.WriteElementString("TotalImpuesto", String.Format("{0:N3}", montoTotalImpuesto.ToString())); writer.WriteElementString("TotalComprobante", String.Format("{0:N3}", totalComprobante.ToString())); writer.WriteEndElement(); // ResumenFactura // 'Estos datos te los tiene que brindar los encargados del area financiera writer.WriteStartElement("Normativa"); writer.WriteElementString("NumeroResolucion", "DGT-R-48-2016"); writer.WriteElementString("FechaResolucion", "07-10-2016 01:00:00"); writer.WriteEndElement(); // Normativa // 'Aqui va la firma, despues la agregamos. writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); } catch (Exception ex) { throw ex; } }</pre> </div> </figure> </div> <div class="example-item" id="0xcda86cb901cbb4cb4f291c474042bafd79579e9f3d00ddeb22f76428bbf3a411-493,,574,"> <div class="bs-example"> <div> <div class="bs-example-title">Example #49</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_49" data-hash="0xcda86cb901cbb4cb4f291c474042bafd79579e9f3d00ddeb22f76428bbf3a411" data-area="493,,574,"> <div class="rating-amount">0</div> <a title="Mark this example as good" href="javascript:app.addRating(1, '49')" class="rating-up btn btn-success" data-id="rating_49"><i class="icon-button icon-thumbs-up"></i></a> <a title="Mark this example as bad" href="javascript:app.addRating(-1,'49')" class="rating-down btn btn-danger" data-id="rating_49"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direct link to this example" href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html#0xcda86cb901cbb4cb4f291c474042bafd79579e9f3d00ddeb22f76428bbf3a411-493,,574,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://csharp.hotexamples.com/site/file?hash=0xcda86cb901cbb4cb4f291c474042bafd79579e9f3d00ddeb22f76428bbf3a411&fullName=appreceita-master%2FUtil.cs&project=leosamtorres%2Fappreceita')">Show file</a> </div> <div class="example-project-info"> <nobr> <span>File:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fleosamtorres%2Fappreceita%2Fblob%2Fmaster%2Fappreceita-master%2FUtil.cs">Util.cs</a> </nobr> <nobr> <span>Project:</span> <a target="_blank" rel="nofollow" href="https://csharp.hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fleosamtorres%2Fappreceita">leosamtorres/appreceita</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="49"> <pre class="line-numbers language-csharp" data-end="574" data-start="494" data-highlight="534,539,540,542,543,544"> public string CriarXmlRequisicao(string strMatricSistema, string usuarioSistema, string ipusuario, string usuariorede, string strAutenticacaoCriptografada = "", string strCaminhoCPR = "", string pSenha = "") { //Rotina que Gera a string de Requisição da Autenticação string strRetorno = ""; string strNomeArquivoXML = ""; XmlTextWriter xmlRequisicao = default(XmlTextWriter); XmlDocument docXML = default(XmlDocument); StreamReader SR = default(StreamReader); try { if (!System.IO.Directory.Exists(ConfigurationSettings.AppSettings["CaminhoXML"].ToString() + "\\XML\\")) { System.IO.Directory.CreateDirectory(ConfigurationSettings.AppSettings["CaminhoXML"].ToString() + "\\XML\\"); } //Procura por um nome de arquivo que ainda não exista //strNomeArquivoXML = AppDomain.CurrentDomain.BaseDirectory + "\\XML\\XML_REQ_AUT_" + String.Format(DateTime.Now, "ddMMyyyyhhmmss") + ".xml"; strNomeArquivoXML = ConfigurationSettings.AppSettings["CaminhoXML"].ToString() + "\\XML\\XML_REQ_AUT_" + DateTime.Now.ToString("ddMMyyyyhhmmss") + ".xml"; while (System.IO.File.Exists(strNomeArquivoXML)) { strNomeArquivoXML = AppDomain.CurrentDomain.BaseDirectory + "\\XML\\XML_REQ_AUT_" + DateTime.Now.ToString("ddMMyyyyhhmmss") + ".xml"; } xmlRequisicao = new System.Xml.XmlTextWriter(strNomeArquivoXML, System.Text.Encoding.UTF8); //INÍCIO DO DOCUMENTO XML xmlRequisicao.WriteStartDocument(); //INÍCIO DA TAG 'REQUISICAO' xmlRequisicao.WriteStartElement("requisicao"); xmlRequisicao.WriteAttributeString("xmlns", "http://ntconsult.com.br/webservices/"); xmlRequisicao.WriteAttributeString("versao", "0.10"); //Caso a Autenticação seja criptografia RSA então este elemento deverá ser criado: AutenticacaoCriptografada //Caso o parâmetro tenha sido informado e não esteja em branco efetua a autenticação através de RSA if ((strAutenticacaoCriptografada != null)) { if (!string.IsNullOrEmpty(strAutenticacaoCriptografada.Trim())) { xmlRequisicao.WriteElementString("AutenticacaoCriptografada", strAutenticacaoCriptografada); } } else { xmlRequisicao.WriteElementString("usr", usuarioSistema); xmlRequisicao.WriteElementString("senha", pSenha); } xmlRequisicao.WriteElementString("matricsistema", strMatricSistema); xmlRequisicao.WriteElementString("usuariorede", usuariorede); xmlRequisicao.WriteElementString("ipusuario", ipusuario); //FIM DA TAG 'REQUISICAO' xmlRequisicao.WriteEndElement(); //FIM DO DOCUMENTO XML xmlRequisicao.WriteEndDocument(); xmlRequisicao.Flush(); xmlRequisicao.Close(); docXML = new XmlDocument(); docXML.PreserveWhitespace = false; SR = File.OpenText(strNomeArquivoXML); docXML.LoadXml(SR.ReadToEnd()); SR.Close(); strRetorno = docXML.InnerXml.ToString(); //apos usar o arquivo, apaga-lo File.Delete(strNomeArquivoXML); return(strRetorno); } catch (Exception ex) { throw ex; } }</pre> </div> </figure> </div> <div id="all-examples"></div> </div> </div> </div> <div class="page-side-banner hidden-xs hidden-sm hidden-md" style="width:300px"> <div id="ezoic-pub-ad-placeholder-131"> <div class="fx" style="width:300px"> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- right-sidebar-fx --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3697522372581514" data-ad-slot="8968655429" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> </div> </div> </div> <footer class="footer"> <div class="container"> <div class="row"> <div class="col-md-12" style="text-align: center"> <a href="https://csharp.hotexamples.com/site/trends?type=csharp%7Cc"> Top Classes </a> | <a href="https://csharpdoc.hotexamples.com/doc/map">Documentation</a> | <a href="/site/privacy">Privacy Policy</a> | <a href="https://cpp.hotexamples.com/direct-sales.html">Advertise with us</a> </div> </div> <div class="row"> <div class="col-md-12" style="text-align: center"> <a href="https://hotexamples.com/">PHP</a> | <a href="https://csharp.hotexamples.com/">C# (CSharp)</a> | <a href="https://java.hotexamples.com/">Java</a> | <a href="https://golang.hotexamples.com/">Golang</a> | <a href="https://cpp.hotexamples.com/">C++ (Cpp)</a> | <a href="https://python.hotexamples.com/">Python</a> | <a href="https://javascript.hotexamples.com/">JavaScript</a> | <a href="https://typescript.hotexamples.com/">TypeScript</a> </div> </div> <div class="row"> <div class="col-md-12" style="text-align: center"> <a href="https://csharp.hotexamples.com/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html">EN</a> | <a href="https://csharp.hotexamples.com/ru/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html">RU</a> | <a href="https://csharp.hotexamples.com/de/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html">DE</a> | <a href="https://csharp.hotexamples.com/fr/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html">FR</a> | <a href="https://csharp.hotexamples.com/es/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html">ES</a> | <a href="https://csharp.hotexamples.com/pt/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html">PT</a> | <a href="https://csharp.hotexamples.com/it/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html">IT</a> | <a href="https://csharp.hotexamples.com/jp/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html">JP</a> | <a href="https://csharp.hotexamples.com/zh/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html">ZH</a> | <a href="https://csharp.hotexamples.com/ko/examples/System.Xml/XmlTextWriter/WriteElementString/php-xmltextwriter-writeelementstring-method-examples.html">KO</a> </div> </div> <div class="row"> <div class="col-md-10 col-md-offset-1"> </div> <div class="col-md-1"> <!--LiveInternet counter--> <script type="text/javascript"><!-- document.write("<a href='//www.liveinternet.ru/click' " + "target=_blank><img src='//counter.yadro.ru/hit?t44.6;r" + escape(document.referrer) + ((typeof (screen) == "undefined") ? "" : ";s" + screen.width + "*" + screen.height + "*" + (screen.colorDepth ? screen.colorDepth : screen.pixelDepth)) + ";u" + escape(document.URL) + ";" + Math.random() + "' alt='' title='LiveInternet' " + "border='0' width='31' height='31'><\/a>"); //--></script><!--/LiveInternet--> </div> </div> </div> </footer> <script src="//ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="/assets/30dd86a6f06b64184847037c52c63e07aa3c9a26.js"></script> <script>jQuery(function ($) { jQuery('#search-form').yiiActiveForm([{"id":"searchform-lang","name":"lang","container":".field-searchform-lang","input":"#searchform-lang","enableAjaxValidation":true},{"id":"searchform-search","name":"search","container":".field-searchform-search","input":"#searchform-search","enableAjaxValidation":true,"validate":function (attribute, value, messages, deferred, $form) {yii.validation.required(value, messages, {"message":"Search cannot be blank."});}}], []); });</script></body> </html>