我希望这段代码能够返回true但不是吗?我在这里错过了什么。
string xml = @"<!DOCTYPE root [ <!ELEMENT e (e*) ><!ATTLIST e id ID #REQUIRED>]>
<data><e id=""NUM_CPUS"">2</e><e id=""ACE_PRESENT"">1</e></data>";
XPathDocument doc = new XPathDocument(new StringReader(xml));
string expr = "(id('NUM_CPUS'))>=1 and (id('ACE_PRESENT'))=1";
XPathNavigator nav = doc.CreateNavigator();
XPathExpression query = nav.Compile(expr);
object result = nav.Evaluate(query);
bool b = bool.Parse(result.ToString());
if (!b)
throw new Exception("Should be true");
答案 0 :(得分:0)
添加标题,使其有效:
<!DOCTYPE root [ <!ELEMENT e (e*) ><!ATTLIST e id ID #REQUIRED>]>