0
이 질문을 모두 게시 파일로 누군가가 더 나은 솔루션이있는 경우 나 파일을 저장 프로 시저에서 형식화 된 XML 출력을 쓰기 위해 노력하고 있어요쓰기 형식의 XML 출력
여기에 (한) 대답은 ... 확인합니다. 내 첫 번째 시도는 다음과 같이 보았다 : 나는 그것을 멋지게 포맷 할
<MyData><row><ID>1</ID><Name>asdf</Name></row></MyData>
: 좋은 짧은, 그러나 생성 된 파일을 모두 한 줄에 박제있다
// the actual command is a stored procedure that returns an XML document, but use this for demo purposes
var xmlCommand = new SqlCommand("SELECT 1 as ID, 'asdf' as Name FOR XML PATH, ROOT('MyData')", conn);
File.WriteAllText("file1.xml", (string)xmlCommand.ExecuteScalar());
<MyData>
<row>
<ID>1</ID>
<Name>asdf</Name>
</row>
</MyData>