Created
May 24, 2018 00:27
-
-
Save WildGenie/da817b98ef15b02bf85ada43698de34d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "System.Xml" | |
#r "System.Xml.Linq" | |
using System.Xml; | |
using System.Xml.Linq; | |
string xmlData = @"<?xml version=""1.0"" encoding=""UTF-8""?> | |
<CATALOG> | |
<CD> | |
<TITLE>Empire Burlesque</TITLE> | |
<ARTIST>Bob Dylan</ARTIST> | |
<COUNTRY>USA</COUNTRY> | |
<COMPANY>Columbia</COMPANY> | |
<PRICE>10.90</PRICE> | |
<YEAR>1985</YEAR> | |
</CD> | |
</CATALOG>"; | |
private class Utf8StringWriter : StringWriter | |
{ | |
public override Encoding Encoding { get { return Encoding.UTF8; } } | |
} | |
var xmldoc = new XmlDocument(); | |
var xdocp = XDocument.Parse(xmlData); | |
var sw = new Utf8StringWriter(); //StringWriter kullanırsan utf-16 kaydediyor | |
xdocp.Save(sw); // "SaveOptions.DisableFormatting" parametresini eklersen formatsız kaydediyor | |
var xdoc = sw.ToString(); | |
xmldoc.LoadXml(xdoc); | |
xdoc.Dump("xdoc"); | |
xmldoc.InnerXml.Dump("xmldoc"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment