2013-10-08 41 views
0

如何使用SelectSingleNode獲取OverallResult元素的內聯字母?從xml文檔中讀取無連接文本

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
<soap:Body> 
    <ProcessResp xmlns="http://www.w3.org/2005/Atom"> 
     <Result> 
      <OverallResult>Success</OverallResult> 
+0

問題要求代碼必須**說明問題的一小部分理解正在解決* *。包括嘗試解決方案,爲什麼他們沒有工作,以及*期望*結果。另見:[堆棧溢出問題清單](http://meta.stackexchange.com/questions/156810/stack-overflow-question-checklist) –

回答

0
var doc = new XmlDocument(); 
doc.LoadXml(xml); 
var text = doc.SelectSingleNode("Example/Node/text()").InnerText; // or .Value 

回報

"Some text here\r\n " 

和text.Trim()返回

"Some text here" 

請通過下面的鏈接,XML相關查詢其begginers非常有用!

http://www.dotnetcurry.com/ShowArticle.aspx?ID=564

你的答案(我havnt嘗試過,雖然在我們的代碼改變這樣的嘗試)

doc.SelectSingleNode("soap/ProcessResp/ Result/OverallResult/text()").InnerText; 
+0

對不起,我很新,發佈問題statkoverflow。我現在添加了xml。 – user1890098

+0

我編輯了我的答案檢查 – Neel