1
我需要的是一個字符串返回代碼中的錯誤,我可以在php
做到這一點,但它需要被轉換爲C#和任何一個把這段代碼轉換爲C#從返回的StreamReader查找錯誤代碼
串
<?xml version="1.0" encoding="UTF-8"?>
<nma>
<error code="402" resettimer="TIMELEFT"></error>
</nma>
preg_match("/<error code=\"(.*?)\".*>(.*?)<\/error>/i", $return, $out);
// return $out[1] = 200;
我都沒有成功
foreach (Match m in Regex.Matches(response, "<error code=\"(.*?)\".*>(.*?)</error>")){
Console.WriteLine("'{0}' found at index {1}.",
m.Value, m.Index);
爲什麼不使用xml解析器?正則表達式不是用於解析xml –