我正在使用 Windows 手机。我需要通过发布到服务器来从我收到的 xml 中获取数据,如下所示
try
{
HttpWebRequest webRequest = (HttpWebRequest)asynchronousResult.AsyncState;
HttpWebResponse response;
response = (HttpWebResponse)webRequest.EndGetResponse(asynchronousResult);
Stream streamResponse = response.GetResponseStream();
StreamReader streamReader = new StreamReader(streamResponse);
var Response = streamReader.ReadToEnd();
streamResponse.Close();
streamReader.Close();
response.Close();
if (Response == "")
{
//show some error msg to the user
}
else
{
//Your response will be available in "Response"
string mystring = Response.ToString();
//Mytext.Text = mystring;
Debug.WriteLine(mystring);
//TRY
XDocument xd = XDocument.Parse(mystring);
Debug.WriteLine(xd);
}
}
我在调试屏幕上得到如下输出
<User><Number>00000</Number><Id>1234</Id><TextKey>1A1A1A1A1A1A1A1A</TextKey><Agent>WindowsPhone</Agent></User>
<User>
<Number>00000</Number>
<Id>1234</Id>
<TextKey>1A1A1A1A1A1A1A1A</TextKey>
<Agent>WindowsPhone</Agent>
</User>
我需要从这个 xml 中提取每个元素并将其用作字符串、int 等。我不需要将它放在列表中 - 我需要单独的每个元素
我怎样才能做到这一点?