MP
前台
<%@ Page language= c# Codebehind= ReadAndWriteXml aspx cs AutoEventWireup= false Inherits= 讀取番茄花園的MP ReadAndWriteXml validateRequest=false%>
<!DOCTYPE HTML PUBLIC //W C//DTD HTML Transitional//EN >
<HTML>
<HEAD>
<title>讀取番茄花園MP 列表</title>
<meta content= Microsoft Visual Studio NET name= GENERATOR >
<meta content= C# name= CODE_LANGUAGE >
<meta content= JavaScript name= vs_defaultClientScript >
<meta content= name= vs_targetSchema >
</HEAD>
<body MS_POSITIONING= GridLayout >
<form id= Form method= post runat= server >
<FONT face= 宋體 >
<asp:TextBox id= TextBox runat= server
Width= px Height= px TextMode= MultiLine ></asp:TextBox>
<asp:Button id= Button runat= server
Width= px Text= 修正~ ></asp:Button></FONT></form>
</body>
</HTML>
後台
using System;
using System Collections;
using System ComponentModel;
using System Data;
using System Drawing;
using System Web;
using System Web SessionState;
using System Web UI;
using System Web UI WebControls;
using System Web UI HtmlControls;
using System IO;
using System Net;
using System Text;
using System Text RegularExpressions;
namespace 讀取番茄花園的MP
{
/// <summary>
/// WebForm 的摘要說明
/// </summary>
public class ReadAndWriteXml : System Web UI Page
{
protected System Web UI WebControls TextBox TextBox ;
protected System Web UI WebControls Button Button ;
private string PageUrl = ;
private void Page_Load(object sender System EventArgs e)
{
// 在此處放置用戶代碼以初始化頁面
if(!IsPostBack)
{
///首先讀取番茄花園的acx文件(_playlist asx)
///
PageUrl = _playlist asx ;
WebClient wc = new WebClient();
wc Credentials = CredentialCache DefaultCredentials;
Byte[] pageData = wc DownloadData(PageUrl);
string Result = Encoding Default GetString(pageData);
TextBox Text=Result;
}
}
#region Web 窗體設計器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調用是 ASP NET Web 窗體設計器所必需的
//
InitializeComponent();
base OnInit(e);
}
/// <summary>
/// 設計器支持所需的方法 不要使用代碼編輯器修改
/// 此方法的內容
/// </summary>
private void InitializeComponent()
{
this Button Click += new System EventHandler(this Button _Click);
this Load += new System EventHandler(this Page_Load);
}
#endregion
private void Button _Click(object sender System EventArgs e)
{
string temp=TextBox Text;
TextBox Text= <musics firstRun=\ \ > ;
TextBox Text+=temp;
TextBox Text=TextBox Text Replace( <Asx Version= > );
TextBox Text=TextBox Text Replace( <Param Name=\ AllowShuffle\ Value=\ yes\ /> );
TextBox Text=TextBox Text Replace( </Asx> );
TextBox Text=TextBox Text Replace( </Entry> );
TextBox Text=TextBox Text Replace( <Entry> );
TextBox Text=TextBox Text Replace( <Title> <music name=\ );
TextBox Text=TextBox Text Replace( </Title> \ );
TextBox Text=TextBox Text Replace( <Ref addres= );
TextBox Text+= </musics> ;
//TextBox Text=TextBox Text Replace( \r\n );
/// 下面開始生成 xml文件
///
StreamWriter swFromFileStreamUTF Buffer=new StreamWriter(Server MapPath( / )+ xml false System Text Encoding UTF );
swFromFileStreamUTF Buffer Write(TextBox Text);
swFromFileStreamUTF Buffer Flush();
swFromFileStreamUTF Buffer Close();
}
}
}
From:http://tw.wingwit.com/Article/program/net/201311/13338.html