admin posted on December 17, 2008 10:26::249 view(s)
Đang viết demo thử làm việc với jQuery, mình phải đụng đến việc đọc file XML. Thế nên, mình tiện thể nghiên cứu luôn các cách cơ bản để đọc và viết file XML. Các code mình sử dụng ở đây đều lấy từ các site mình search được trên Google.
Đầu tiên ta tạo các biến lưu đường dẫn đến các file xml
private string strImageXMLFilePath = Null.NullString;
private string strImageXMLFilePathInServer = Null.NullString;
protected void Page_Load(System.Object sender, System.EventArgs e)
{
try
{
strImageXMLFilePath = ModulePath + "xml/ImageList.xml";
strImageXMLFilePathInServer = Server.MapPath(strImageXMLFilePath);
strImageXMLFilePath_1 = ModulePath + "xml/ImageList1.xml";
strImageXMLFilePathInServer_1 = Server.MapPath(strImageXMLFilePath_1);
Đây là hàm load toàn bộ nội dung file và đưa ra textbox. Ta không xử lý gì. Nội dung file được đưa vào StreamReader. Cách này được dùng nếu ta có ý đưa file cho 1 bên thứ ba (ví dụ như Flash code) xử lý.
[Read the rest of this article...]