从XML中提取内部文本

时间:2013-09-05 10:09:57

标签: c# xml

<?xml version="1.0" encoding="utf-8"?>
<my:myFields ..........>
<my:ProjectDeliverables>
    <html xmlns="http://www.w3.org/1999/xhtml" xml:space="preserve">
        <p>
        ​    ​<span id="ms-rterangepaste-start"></span>
        ​    <div>Deliverables will include but are not limited to:</div>
        ​    <div><span style="font-family:symbol"><span>·<span style="font:7pt 'times new roman'">         </span></span></span>Feature sets identified by management for Production release of Pfx.Net application.</div>
       ​     <div><span style="font-family:symbol"><span>·<span style="font:7pt 'times new roman'">         </span></span></span>SQL server performance tuning reports</div>
         ​   <div><span style="font-family:symbol"><span>·<span style="font:7pt 'times new roman'">         </span></span></span>SQL alter scripts for each development build</div>
​    ​    ​    ​<span id="ms-rterangepaste-end"></span>
​    ​    ​</p>
    </html>
</my:ProjectDeliverables>

我正在使用以下内容: -

XmlNodeList nodelist1 = xml.GetElementsByTagName("my:myFields");

key_deliverables = node["my:ProjectDeliverables"].InnerText;

但这不起作用。

2 个答案:

答案 0 :(得分:0)

XmlNodeList nodelist1 = xml.GetElementsByTagName("my:myFields");
var key_deliverables = nodelist1[0].InnerText;

答案 1 :(得分:0)

您需要包含以下xml名称空间声明:

使用XMLNAMESPACES('http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-09-10T21:30:46'作为我的