밑에 생성한 test.xml파일을 StreamReader클레스를 이용해서요
테이터를 읽어 온다음에요
using System;
using System.IO;
using System.Text;
class FSOpenWrite {
public static void Main() {
// string strXml = ""
// +"<?xml version='1.0'?>\r\n"
// +"<Books>\r\n"
// +" <Book>\r\n"
// +" <Author>Andrew Troelson</Author>\r\n"
// +" <Title>C#과 닷넷 플랫폼</Title>\r\n"
// +" <Price>40000</Price>\r\n"
// +" </Book>\r\n"
// +" <Book>\r\n"
// +" <Author>김순근</Author>\r\n"
// +" <Title>ASP.NET Bible</Title>\r\n"
// +" <Price>38000</Price>\r\n"
// +" </Book>\r\n"
// +"</Books>\r\n";
string path = @"c:\_todo\text.xml";
try{
using (StreamReader sr = new StreamReader(path)) {
Console.WriteLine(sr.ReadToEnd());
//웹브라우저로 보기
//System.Diagnostics.Process.Start("iexplore.exe", path);
}
}
catch(Exception e){
Console.WriteLine(e.Message);
}
}
}
이렇게 하면 읽어 올수 있는데요 .
----------------------------------------------------------------------
XML파일의 내용을 읽어서.
파일에서 기술한 책의 권수와, 모든 책의 금액을 합한 합계와 평균을 구하는 프로그램을 작성하시오.
XmlTextReader클래스를 사용하지 말고 StreamReader 클래스를 이용
여기서 이 데이터 요소를 어찌 가져와야 하나요?