问 xml 解析失败的问题
帮我看下错哪里了用上面的HTML,页面点按钮,就能返回正确的结果
为什么用C#做的页面就解析错误呢?错误代码-1072896680
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>test</title>
</HEAD>
<BODY>
<form method="post" action="http://192.168.0.11/trans_api/QueryOrdertest.asp">
<INPUT TYPE="submit" value="submit" id="Submit"><br />
XML:<br />
<textarea name="FK" style="width: 451px; height: 133px"><?xml version="1.0" encoding="UTF-8"?>
<root>
<QueryOrder version="2.0">
<mailNo>864356040</mailNo>
</QueryOrder>
</root>
</textarea><br />
<br />
</form>
</BODY>
</HTML>
---------------------------
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Web;
using
using
using System.Text.RegularExpressions;
using System.Security.Cryptography;
namespace XML
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string url = @"http://192.168.0.11/trans_api/QueryOrdertest.asp";
string xml = "";
xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>";
xml = xml + @"<root>";
xml = xml + @"<QueryOrder version=""2.0"">";
xml = xml + @"<mailNo>864356040</mailNo>";
xml = xml + @"</QueryOrder>";
xml = xml + @"</root>";
// Post(url, xml);
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
myRequest.Method = "POST";
myRequest.ContentType = "Content-type,text/xml;charset=UTF-8";
myRequest.ContentLength = xml.Length;
Stream newStream = myRequest.GetRequestStream();
// Send the data. 13.
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] postdata = encoding.GetBytes(xml);
newStream.Write(postdata, 0, xml.Length);
newStream.Close();
// Get response 18.
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
string content = reader.ReadToEnd();//得到结果
richTextBox1.Text = content;
richTextBox2.Text = xml;
}
}
}