我想检查一个 xml 字符串,它是否在 C# 中具有指定的开始和结束标记。xml字符串如下。
string xml=@"<iq from='someone' to='someone' id='1234' type='result'><query xmlns='jabber:iq:hello' type='hello'><question questionid='17' postedon='1376148890' editedon='1376150411' categoryid='1034' categoryname='Computer' postedby='mohan' viewstatus='0' availability='offline'>Hello</question></query></iq>";
<iq from='someone' to='someone' id='1234' type='result'>
<query xmlns='jabber:iq:hello' type='hello'>
<question questionid='17' postedon='1376148890' editedon='1376150411' categoryid='1034' categoryname='Computer' postedby='mohan' viewstatus='0' availability='offline'>Hello</question>
</query>
</iq>
我一直在使用以下正则表达式格式进行检查,但这对我没有帮助
var regexForIq = new Regex(@"<iq(.*?)</iq>", RegexOptions.IgnoreCase);
var iqMatch = regexForIq.Match(_responseData);
提前致谢。