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


C# XmlWriterSettings类代码示例

本文整理汇总了C#中XmlWriterSettings的典型用法代码示例。如果您正苦于以下问题:C# XmlWriterSettings类的具体用法?C# XmlWriterSettings怎么用?C# XmlWriterSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        var pathSVGIcons = Server.MapPath("~/Composite/images/icons/svg/");

        XNamespace svgNamespace = @"http://www.w3.org/2000/svg";

        var svgSprite = XElement.Parse(svgBlank);

        var defs = svgSprite.Descendants(svgNamespace + "defs").First();

        foreach (var file in Directory.GetFiles(pathSVGIcons))
        {
            var id = Path.GetFileNameWithoutExtension(file);
            var svgElement = XElement.Load(file);

            var taggetGroup = svgElement.Descendants(svgNamespace + "g").FirstOrDefault(el => (string) el.Attribute("id") == id);

            if (taggetGroup != null)
            {
                defs.Add(taggetGroup);
            }
        }

           var settings = new XmlWriterSettings {OmitXmlDeclaration = true};

        using (XmlWriter xw = XmlWriter.Create(PathUtil.Resolve("~/Composite/images/sprite.svg"), settings))
        {
            svgSprite.Save(xw);
        }
    }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:30,代码来源:GenerateIconSprite.aspx.cs

示例2: Start

    // Use this for initialization
    void Start()
    {
        playerData = new PlayerData1("PkerkidHD", 10.0f);

        XmlWriterSettings xmlWriterSettings = new XmlWriterSettings()
        {
            Indent = true,
            IndentChars = "\t",
            NewLineOnAttributes = true
        };

        using (XmlWriter xml = XmlWriter.Create("PlayerData.xml", xmlWriterSettings)) {

            //ROOT
            xml.WriteStartDocument();
            xml.WriteStartElement("PlayerData");

            xml.WriteStartElement("Player");
            xml.WriteElementString("PlayerName", playerData.PlayerName);
            xml.WriteElementString("Money", playerData.Money.ToString());
            xml.WriteEndElement();

            // End.
            xml.WriteEndElement();
            xml.WriteEndDocument();
            xml.Flush();
        }

        Debug.Log ("DONE");
    }
开发者ID:pkerkidhd,项目名称:CourierExpressTycoon,代码行数:31,代码来源:SaveManager.cs

示例3: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         DateTime dt = new DateTime();
         XmlWriterSettings xws = new XmlWriterSettings();
         xws.Indent = true;
         xws.IndentChars=("  ");
         xws.ConformanceLevel = ConformanceLevel.Fragment;
         XmlWriter xwr = XmlWriter.Create(Server.MapPath("stu.xml"), xws);
         try
         {
             xwr.WriteStartElement("userinfo");
             xwr.WriteStartElement("user");
             xwr.WriteElementString("name","zhangsan");
             xwr.WriteEndElement();
             xwr.WriteStartElement("user");
             xwr.WriteElementString("name", "Jim john");
             xwr.WriteEndElement();
             xwr.WriteStartElement("user");
             xwr.WriteElementString("name", "Marry");
             xwr.WriteEndElement();
             xwr.WriteEndElement();
             xwr.Flush();
             xwr.Close();
         }
         catch (Exception ex)
             {
             xwr.Close();
                 TextBox2.Text=ex.Message.ToString();
             }
     }
     mydom.Load(Server.MapPath("cat1.xml"));
 }
开发者ID:red201432,项目名称:MyWeb,代码行数:34,代码来源:xml.aspx.cs

示例4: Transform

    public static string Transform(string xsltFile, string xml, XsltArgumentList xslArg)
    {
        string result = "";
        try {

        XslCompiledTransform xslt = new XslCompiledTransform();
        xslt.Load(xsltFile);
        // XmlWriterSettings.OmitXmlDeclaration

        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(new StringReader(xml));

        XmlWriterSettings settings = new XmlWriterSettings();
        settings.Indent = true;
        settings.OmitXmlDeclaration = true;
        settings.NewLineOnAttributes = true;

        using (StringWriter sw = new StringWriter()) {
        using (XmlWriter writer = XmlWriter.Create(sw, settings)) {
            xslt.Transform(xmlDoc, xslArg, writer);
        }
        sw.Flush();
        result = sw.ToString();
          }
        } catch (Exception ex) {
        Console.WriteLine(ex.ToString());
        }
        return result;
    }
开发者ID:xesrochers,项目名称:bijou,代码行数:29,代码来源:XmlUtils.cs

示例5: ToXml

 internal static string ToXml(this object item)
 {
     if (item == null)
         return null;
     try
     {
         using (var stream = new StringWriter())
         {
             var settings = new XmlWriterSettings();
             settings.Indent = false;
             settings.OmitXmlDeclaration = true;
             using (var writer = XmlWriter.Create(stream, settings))
             {
                 var serializer = new XmlSerializer(item.GetType());
                 var emptyNamepsaces = new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty });
                 serializer.Serialize(writer, item, emptyNamepsaces);
                 return stream.ToString();
             }
         }
     }
     catch
     {
         throw;
     }
 }
开发者ID:joaofiliperocha,项目名称:Web,代码行数:25,代码来源:TypeConvertExt.cs

示例6: Main

 public static void Main(string[] args)
 {
     AtomXmlReader reader = new AtomXmlReader();
     reader.DocumentTypeDetected += delegate(object sender, DocumentTypeDetectedEventArgs e) {
       if (!e.DocumentType.IsAssignableFrom(typeof(AtomEntry))) {
     e.HaltFurtherProcess = true;
       }
     };
     try {
       if (args.Length == 0) {
     Stream input = Console.OpenStandardInput();
     XmlWriterSettings settings = new XmlWriterSettings();
     settings.Indent = true;
     reader.ReadDocument(input).WriteDocument(Console.Out, settings);
       }
       else {
     foreach (string feedLocation in args) {
       XmlWriterSettings settings = new XmlWriterSettings();
       settings.Indent = true;
       reader.ReadDocument(feedLocation).WriteDocument(Console.Out, settings);
       break;
     }
       }
     }
     catch (ArgumentException e) {
       Console.Error.WriteLine(e.Message);
     }
 }
开发者ID:hazychill,项目名称:webfeed,代码行数:28,代码来源:dispentry.cs

示例7: Start

    // Use this for initialization
    void Start()
    {
        cardList.Add(new CreatureCard());
        cardList.Add(new CreatureCard("アリスに化けたマミゾウ"));
        XmlSerializer xmls = new XmlSerializer(typeof(List<CreatureCard>));

        XmlWriterSettings settings = new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true };
        using (var stream = File.OpenWrite("cardList.xml"))
        {
            using (var xmlWriter = XmlWriter.Create(stream, settings))
            {
                xmls.Serialize(xmlWriter, cardList);
            }
        }

        Type[] extraTypes = { typeof(Land), typeof(LiveableLand) };
        xmls = new XmlSerializer(typeof(Map),extraTypes);
        using (var stream = File.OpenWrite("map.xml"))
        {
            using (var xmlWriter = XmlWriter.Create(stream, settings))
            {
                xmls.Serialize(xmlWriter, map);
            }
        }
    }
开发者ID:rokushou66,项目名称:thCuld,代码行数:26,代码来源:XmlSaveTest.cs

示例8: Awake

	void Awake(){
		player1HandPosition = GameObject.Find ("Canvas/Player1Hand");
		CL = GameObject.Find ("CardLoader").GetComponent<CardLoader>();
		using (XmlReader reader = XmlReader.Create (new StreamReader (Application.persistentDataPath + "/Decks/DeckList.xml"))) {
			XmlWriterSettings ws = new XmlWriterSettings ();
			ws.Indent = true;
			while (reader.Read ()) {
				switch (reader.NodeType) {
				case XmlNodeType.Element:
					switch (reader.Name) {
					case "Deck":
						deckName = reader.GetAttribute ("Name");
						//Debug.Log (deckName);
						break;
					}
					break;
				case XmlNodeType.Text:
					//Debug.Log (reader.Value);
					line = reader.Value;
					break;
				}
			}
		}
		player1Deck = line.Split (',').ToList<string> ();
		player1Deck.RemoveAt (player1Deck.Count - 1); // Remove the blank string at the end of the list of cards
		RandomizeDeck(player1Deck);
		DrawStartingHands (player1Deck);
		//Debug.Log (player1Deck.Count);
		DisplayHand(player1HandPosition, player1Hand);

	}
开发者ID:massiecb,项目名称:496,代码行数:31,代码来源:GameLoop1.cs

示例9: XmlWriterTraceListener

		public XmlWriterTraceListener (TextWriter writer, string name)
			: base (writer, name)
			{
			XmlWriterSettings settings = new XmlWriterSettings ();
			settings.OmitXmlDeclaration = true;
			w = XmlWriter.Create (writer, settings);
			}
开发者ID:oznetmaster,项目名称:SSMonoDiagnosticsLibrary,代码行数:7,代码来源:XmlWriterTraceListener.cs

示例10: SaveGame

	public void SaveGame(string savePath){
		//Create a folder for saves incase it does not already exist
		string saveFolder = Directory.GetCurrentDirectory () + "/Saves";
		if (!Directory.Exists (saveFolder))
			Directory.CreateDirectory (saveFolder);

		//Setup Xml writer and file-stream
		XmlWriterSettings ws = new XmlWriterSettings ();
		ws.Indent = true;
		ws.Encoding = Encoding.UTF8;
		//Setup the writer and ouptut
		using (FileStream fs = new FileStream (saveFolder + '/' + savePath + ".xml", FileMode.Create)) {
			using (XmlWriter writer = XmlWriter.Create (fs, ws)) {
				//Write start of document
				writer.WriteStartDocument ();
				writer.WriteStartElement ("Save");

				//Add things to save here!
				_player.GetComponent<Wizard> ().Save (writer);
				SaveEnemies (writer);

				writer.WriteEndElement ();
				writer.WriteEndDocument ();
			}
		}
	}
开发者ID:TobiasMorell,项目名称:Game2Grow-Wizard,代码行数:26,代码来源:SaveLoadManager.cs

示例11: DisposeFlushesAndDisposesOutputStream

        public static void DisposeFlushesAndDisposesOutputStream()
        {
            bool[] asyncValues = { false, true };
            bool[] closeOutputValues = { false, true };
            bool[] indentValues = { false, true };
            bool[] omitXmlDeclarationValues = { false, true };
            bool[] writeEndDocumentOnCloseValues = { false, true };
            foreach (var async in asyncValues)
                foreach (var closeOutput in closeOutputValues)
                    foreach (var indent in indentValues)
                        foreach (var omitXmlDeclaration in omitXmlDeclarationValues)
                            foreach (var writeEndDocumentOnClose in writeEndDocumentOnCloseValues)
                            {
                                using (MemoryStream ms = new MemoryStream())
                                {
                                    XmlWriterSettings settings = new XmlWriterSettings();
                                    // UTF8 without BOM
                                    settings.Encoding = new UTF8Encoding(false);
                                    settings.Async = async;
                                    settings.CloseOutput = closeOutput;
                                    settings.Indent = indent;
                                    settings.OmitXmlDeclaration = omitXmlDeclaration;
                                    settings.WriteEndDocumentOnClose = writeEndDocumentOnClose;
                                    XmlWriter writer = XmlWriter.Create(ms, settings);
                                    writer.WriteStartDocument();
                                    writer.WriteStartElement("root");
                                    writer.WriteStartElement("test");
                                    writer.WriteString("abc");
                                    // !!! intentionally not closing both elements
                                    // !!! writer.WriteEndElement();
                                    // !!! writer.WriteEndElement();
                                    writer.Dispose();

                                    if (closeOutput)
                                    {
                                        bool failed = true;
                                        try
                                        {
                                            ms.WriteByte(123);
                                        }
                                        catch (ObjectDisposedException) { failed = false; }
                                        if (failed)
                                        {
                                            throw new Exception("Failed!");
                                        }
                                    }
                                    else
                                    {
                                        string output = ReadAsString(ms);
                                        Assert.True(output.Contains("<test>abc"));
                                        Assert.NotEqual(output.Contains("<?xml version"), omitXmlDeclaration);
                                        Assert.Equal(output.Contains("  "), indent);
                                        Assert.Equal(output.Contains("</test>"), writeEndDocumentOnClose);
                                    }

                                    // should not throw
                                    writer.Dispose();
                                }
                            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:60,代码来源:DisposeTests.cs

示例12: default_2

        //[Variation(id=2, Desc="Default value of OmitXmlDeclaration")]
        public int default_2()
        {
            XmlWriterSettings wSettings = new XmlWriterSettings();
            CError.Compare(wSettings.OmitXmlDeclaration, false, "Incorrect default value of OmitXmlDeclaration");

            return TEST_PASS;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:8,代码来源:XmlFactoryWriterTests.cs

示例13: XmlQueryStaticData

        /// <summary>
        /// Constructor.
        /// </summary>
        public XmlQueryStaticData(XmlWriterSettings defaultWriterSettings, IList<WhitespaceRule> whitespaceRules, StaticDataManager staticData)
        {
            Debug.Assert(defaultWriterSettings != null && staticData != null);
            _defaultWriterSettings = defaultWriterSettings;
            _whitespaceRules = whitespaceRules;
            _names = staticData.Names;
            _prefixMappingsList = staticData.PrefixMappingsList;
            _filters = staticData.NameFilters;
            _types = staticData.XmlTypes;
            _collations = staticData.Collations;
            _globalNames = staticData.GlobalNames;
            _earlyBound = staticData.EarlyBound;

#if DEBUG
            // Round-trip check
            byte[] data;
            Type[] ebTypes;
            this.GetObjectData(out data, out ebTypes);
            XmlQueryStaticData copy = new XmlQueryStaticData(data, ebTypes);

            _defaultWriterSettings = copy._defaultWriterSettings;
            _whitespaceRules = copy._whitespaceRules;
            _names = copy._names;
            _prefixMappingsList = copy._prefixMappingsList;
            _filters = copy._filters;
            _types = copy._types;
            _collations = copy._collations;
            _globalNames = copy._globalNames;
            _earlyBound = copy._earlyBound;
#endif
        }
开发者ID:Corillian,项目名称:corefx,代码行数:34,代码来源:XmlQueryStaticData.cs

示例14: SaveXmlLevel

	public static void SaveXmlLevel(ABLevel level) {

		StringBuilder output = new StringBuilder();
		XmlWriterSettings ws = new XmlWriterSettings();
		ws.Indent = true;

		using (XmlWriter writer = XmlWriter.Create(output, ws))
		{
			writer.WriteStartElement("Level");

			writer.WriteStartElement("BirdsAmount");
			writer.WriteValue(level.birdsAmount);
			writer.WriteEndElement();

			writer.WriteStartElement("GameObjects");

			foreach(ABGameObject abObj in level.gameObjects)
			{
				writer.WriteStartElement("GameObject");
				writer.WriteAttributeString("label", abObj.Label.ToString());
				writer.WriteAttributeString("x", abObj.Position.x.ToString());
				writer.WriteAttributeString("y", abObj.Position.y.ToString());
				writer.WriteEndElement();
			}
		}

		int levelsAmountInResources = LoadAllLevels().Length;

		StreamWriter streamWriter = new StreamWriter("Assets/Resources/GeneratedLevels/genetic-level-" + (levelsAmountInResources + 1) + ".xml");
		streamWriter.WriteLine(output.ToString());
		streamWriter.Close();
	}
开发者ID:Elinion,项目名称:AngryBirds-PCG,代码行数:32,代码来源:LevelLoader.cs

示例15: WriteWithEncoding

        public static void WriteWithEncoding()
        {
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.OmitXmlDeclaration = true;
            settings.ConformanceLevel = ConformanceLevel.Fragment;
            settings.CloseOutput = false;
            settings.Encoding = Encoding.GetEncoding("Windows-1252");
            MemoryStream strm = new MemoryStream();

            using (XmlWriter writer = XmlWriter.Create(strm, settings))
            {
                writer.WriteElementString("orderID", "1-456-ab\u0661");
                writer.WriteElementString("orderID", "2-36-00a\uD800\uDC00\uD801\uDC01");
                writer.Flush();
            }

            strm.Seek(0, SeekOrigin.Begin);
            byte[] bytes = new byte[strm.Length];
            int bytesCount = strm.Read(bytes, 0, (int)strm.Length);
            string s = settings.Encoding.GetString(bytes, 0, bytesCount);

            Assert.Equal("<orderID>1-456-ab&#x661;</orderID><orderID>2-36-00a&#x10000;&#x10401;</orderID>", s);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:25,代码来源:WriteWithEncoding.cs


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