鑑於此XML,如何使用xpath查詢選擇PostBack的值?使用xpath選擇元素值
<AuthenticateResponse xmlns="http://example.com/authentication/response/1">
<Status>success</Status>
<Result>more-info</Result>
<StateContext />
<AuthenticationRequirements>
<PostBack>/Authentication/ExplicitForms/AuthenticateAttempt</PostBack>
<CancelPostBack>/Authentication/ExplicitForms/CancelAuthenticate</CancelPostBack>
<CancelButtonText>Cancel</CancelButtonText>
</AuthenticationRequirements>
</AuthenticateResponse>
我希望這個工作,但它返回null:
var nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("AuthenticateResponse", "http://example.com/authentication/response/1");
var node = doc.SelectSingleNode("//AuthenticateResponse:AuthenticationRequirements/PostBack", nsmgr);
工程就像一個魅力,是否有鏈接文檔在哪裏解釋? – Remko