Created
May 8, 2012 09:55
-
-
Save pinzolo/2633943 to your computer and use it in GitHub Desktop.
XML文字列からXDocumentに読み込む
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
using System; | |
using System.IO; | |
using System.Text; | |
using System.Xml.Linq; | |
// 先頭に改行が入ると Load 時に例外発生 | |
String xml = @"<foo> | |
<bar>hoge</bar> | |
<baz>fuga</baz> | |
</foo>"; | |
using (var stream = new MemoryStream(Encoding.Unicode.GetBytes(xml))) | |
{ | |
var doc = Xdocument.Load(stream); | |
// do something ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment