我遇到了一個不尋常的問題。我有這樣的XML:XPath表達式中的點與斜槓
<T durationMs="400">
<foo durationMs="407">
<foo-child durationMs="307" />
</foo>
<bar durationMs="208">
<bar-child durationMs="108" />
</bar>
</T>
我使用XPathExtentions得到一個的XElement出這個XML的:
var xe = XElement.Parse(s);
var foo = xe.XPathSelectElement("/T/foo")
它沒有返回。但是,如果我使用:
var foo = xe.XPathSelectElement("./foo")
它得到一個元素。那麼在這種情況下點和斜線有什麼區別?
我明白了! XDocument可以使用一個根,對嗎? – Schultz9999
@ Schultz9999看看[this](http://msdn.microsoft.com/en-us/library/ms256471.aspx) – Anirudha