Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#从XML文件中获取标记数据(包括内部标记)_C#_Xml_String - Fatal编程技术网

C#从XML文件中获取标记数据(包括内部标记)

C#从XML文件中获取标记数据(包括内部标记),c#,xml,string,C#,Xml,String,我有以下XML文件: <organizations default="pre-test_organization"> <organization identifier="data"> <title>Date</title> <item identifier="5BD294BF-0722-45FC-B888-9F31CD076BF9" ident

我有以下XML文件:

<organizations default="pre-test_organization">
    <organization identifier="data">
        <title>Date</title>
        <item identifier="5BD294BF-0722-45FC-B888-9F31CD076BF9" identifierref="resource">
            <title>Reference</title>
        </item>
    </organization>
</organizations>
<resources>
    <resource identifier="resource" type="webcontent" adlcp:scormtype="sco" href="res/index.html">
        <file href="res/data/apple-touch-icon.png"/>
        <file href="res/data/browsersupport.js"/>
    </resource>
</resources>
返回(上下文正确):

而不是(我真正想要的):

参考

尝试获取
InnerXml

var node = doc.SelectSingleNode("/organizations/organization/item").InnerXml;


最好使用LINQ转换为XML。自2007年以来,它在.Net Framework中可用。
Reference
<title>Reference</title>
var node = doc.SelectSingleNode("/organizations/organization/item").InnerXml;
var lst = root.GetElementsByTagName("item")[0].InnerXml;