我有一个这样的xml文件。
<response>
<status>ok</status>\r\n
<number>125698</number>
</response>
如果状态为“ok”,我想读取数字。所以这是我的代码
using (XmlReader reader = XmlReader.Create(new StringReader(Response)))
{
reader.ReadToFollowing("response");
reader.MoveToFirstAttribute();
reader.ReadToFollowing("status");
output.AppendLine(reader.ReadElementContentAsString());
}
OrderResponse = output.ToString();
OrderResponse = OrderResponse.Replace("\r\n", "");
if (OrderResponse == "ok")
{
using (XmlReader reader = XmlReader.Create(new StringReader(Response)))
{
reader.ReadToFollowing("response");
reader.MoveToNextAttribute();
reader.ReadToFollowing("number");
output.AppendLine(reader.ReadElementContentAsString());
}
string orderNo = output.ToString();
orderNo = orderNo.Replace("\r\n", "");
HttpContext.Current.Session["orderNo"] = orderNo;
但 orderNo 输出像“ok125698”。但我只想要“125698”这个。怎么读?