C# 如何从该XML的特定元素检索文本?
我第一次试图弄明白Xmldocument。我不知道如何从xml文件中提取单个元素。我需要在xml文档中找到某个url,并确定用户是否有权访问该url,如果用户没有权限,则删除与该文章相关的xml 我需要知道如何从以下xml中的C# 如何从该XML的特定元素检索文本?,c#,asp.net,xml,xmldocument,C#,Asp.net,Xml,Xmldocument,我第一次试图弄明白Xmldocument。我不知道如何从xml文件中提取单个元素。我需要在xml文档中找到某个url,并确定用户是否有权访问该url,如果用户没有权限,则删除与该文章相关的xml 我需要知道如何从以下xml中的提取内部文本 <?xml version="1.0" encoding="UTF-8"?> <searchdoc><results hits="3226" time="0.33" query="test" suggest="test1" fil
提取内部文本
<?xml version="1.0" encoding="UTF-8"?>
<searchdoc><results hits="3226" time="0.33" query="test" suggest="test1" filter="" sort="relevance" sortdir="desc" start="1" end="10" currentpage="1" lastpage="323" startdate="0" enddate="0" xsl="Trane.xsl">
<result no="1"><url>c:\RECYCLER\S-1-5-21-3289705215-1832128825-2807327032-470872\Dc115
\test-files\test.ppt</url><col>3</col><lastmodified>25 Feb 2011 20:14:41
GMT</lastmodified><indexdate>11 Mar 2011 20:40:17 GMT</indexdate><size>75264</size>
<title><highlight>Test</highlight></title><alpha>Test</alpha><keywords
/><contenttype>PPT</contenttype><context>Nutch Parser <highlight>Test</highlight> My
initial <highlight>test</highlight> file for the PowerPoint parser of nutch Second
page <highlight>Test</highlight> Of PowerPoint Extraction Some Unicode I do not know
the content and I can not read it, just gathered from other ppt-files: áéíóú Stephan
Strittmatter</context><description>Nutch Parser <highlight>Test</highlight> My initial
<highlight>test</highlight> file for the PowerPoint parser of nutch ...</description>
<language>en</language><score>100</score></result>
c:\RECYCLER\S-1-5-21-3289705215-1832128825-2807327032-470872\Dc115
\测试文件\test.ppt325 2011年2月20:14:41
GMT11 2011年3月20:40:17 GMT75264
TestPPTNutch解析器测试我的
nutch Second PowerPoint解析器的初始测试文件
页面测试的PowerPoint提取一些Unicode我不知道
内容我看不懂,只是从其他ppt文件中收集的:áêíóúStephan
StrittmatterNutch解析器测试我的首字母
nutch的PowerPoint解析器的测试文件。。。
en100
很抱歉,我直接从存储XML的字符串中提取了混乱的XML。我省略了xml的其余部分,因为它很长。如何访问所需信息?使用LINQ的XDocument: 在我看来,语法可能有点错误
XDocument doc = XDocument.Parse(yourString);
string url = (from x in doc.Descendants("url") select x.Value).FirstOrDefault();
使用LINQ的XDocument: 在我看来,语法可能有点错误
XDocument doc = XDocument.Parse(yourString);
string url = (from x in doc.Descendants("url") select x.Value).FirstOrDefault();
阅读XPath和XmlDocument的SelectSingleNode方法阅读XPath和XmlDocument的SelectSingleNode方法