看板 C_Sharp 關於我們 聯絡資訊
試試這味 XDocument doc = XDocument.Parse("<test></test>"); using (MemoryStream stream = new MemoryStream()) { StreamWriter writer = new StreamWriter(stream, Encoding.ASCII); doc.Save(writer); stream.Position = 0; return new StreamReader(stream).ReadToEnd(); } ※ 引述《godsing (執著是苦)》之銘言: : 如題 : XNamespace xmlns = "http://www.microsoft.com/networking/WLAN/profile/v1"; : XDocument xdoc = new XDocument( : new XDeclaration("1.0","US-ASCII",null), : .......... : ....... : ); : StringWriter sw = new StringWriter(); : xdoc.Save(sw); : return sw.ToString(); : 請問要怎樣改成encoding ASCII?? : 不管怎樣它都輸出UTF-16.... : 感覺不難,結果GOOGLE出奇的難找..... : 感謝解答 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.24.150.140 ※ 編輯: flamo 來自: 114.24.150.140 (05/27 23:43)
godsing:thx 來試試看! 05/28 11:33
godsing:我想傳出一個strint(含xml)該怎麼做? 05/28 17:02
flamo:回傳的不就是你要的嗎? 舉個例吧 05/28 18:00
godsing:我要傳出的是一個string,裡面是一個ascii的xml架構 05/28 18:41
godsing:這個string 要傳給一個function 05/28 18:41