在此Web應用程序中,我想向移動廣告發送短信。這是我的aspx.cs文件的代碼:將xml文件轉換爲文本
protected void buttonSendOnClick(object sender, EventArgs e)
{
//are required fields filled in:
if (textboxRecipient.Text == "")
{
textboxError.Text += "Recipient(s) field must not be empty!\n";
textboxError.Visible = true;
return;
}
//we creating the necessary URL string:
string ozSURL = "http://127.0.0.1"; //where Ozeki NG SMS Gateway is running
string ozSPort = "9501"; //port number where Ozeki NG SMS Gateway is listening
string ozUser = HttpUtility.UrlEncode("admin"); //username for successful login
string ozPassw = HttpUtility.UrlEncode("abc123"); //user's password
string ozMessageType = "SMS:TEXT"; //type of message
string ozRecipients = HttpUtility.UrlEncode(textboxRecipient.Text); //who will
//get the message
string ozMessageData = HttpUtility.UrlEncode(textboxMessage.Text); //body of
//message
string createdURL = ozSURL + ":" + ozSPort + "/httpapi" +
"?action=sendMessage" +
"&username=" + ozUser +
"&password=" + ozPassw +
"&messageType=" + ozMessageType +
"&recipient=" + ozRecipients +
"&messageData=" + ozMessageData;
try
{
//Create the request and send data to Ozeki NG SMS Gateway Server by HTTP
connection
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(createdURL);
//Get response from Ozeki NG SMS Gateway Server and read the answer
HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
System.IO.StreamReader respStreamReader = new
System.IO.StreamReader(myResp.GetResponseStream());
string responseString = respStreamReader.ReadToEnd();
respStreamReader.Close();
myResp.Close();
//inform the user
string result = Regex.Replace(responseString, @"<[^>]*>", string.Empty);
textboxError.Text = Server.HtmlEncode(result);
textboxError.Visible = true;
}
catch (Exception)
{
//if sending request or getting response is not successful Ozeki NG SMS
Gateway Server may do not run
textboxError.Text = "Ozeki NG SMS Gateway Server is not running!";
textboxError.Visible = true;
}
}
後,我跑我的文字作爲XML文檔這樣
<Responses>
<Response0>
<Action>sendMessage</Action>
<Data>
<AcceptReport>
<StatusCode>0</StatusCode>
<StatusText>Message accepted for delivery</StatusText>
<MessageID>89c8011c-e291-44c3-ac72-cd35c76cb29d</MessageID>
<Recipient>+85568922903</Recipient>
</AcceptReport>
</Data>
</Response0>
</Responses>
但我想它diplay作爲
接受留言送貨 信息ID:IEUHSHIL 收信人:+441234567
那麼我該怎麼做?
使用'XDocument'或'XMLDocument' – EaterOfCode 2012-08-09 08:10:09
我該怎麼做?我是新的 – 2012-08-09 08:13:29
89c8011c-e291-44c3-ac72-cd35c76cb29d是否轉換爲IEUHSHIL?怎麼樣? – 2012-08-09 08:14:28