【发布时间】:2014-04-25 15:23:01
【问题描述】:
我希望能够从跨度类访问文本,同时还能够获取跨度类之外的信息。例如:
这是我的 XML 文档信息示例:
<item><title>Operations Applications - MDI Diagnostics</title><link>http://confidential-link.com</link>
<description><![CDATA[<div style="margin-top:5px"><link rel="stylesheet" type="text/css" href="confidential" />
<span class="srch-Icon"><a href="confidential" title="Operations Applications - MDI Diagnostics">
<img src="confidential" alt="Web Page" border="0" /></a></span>
<span class="psrch-Description"> THE INFORMATION I WANT</span>
<p class="srch-Metadata"><span class="srch-URL">
<a href="confidential" title="Operations Applications - MDI Diagnostics">confidential link</a>
-
66KB
</span></p></div>]]></description>
<author>Bob Smith
</author><pubDate>Mon, 10 Mar 2014 18:53:49 GMT</pubDate><search:dotfileextension>.ASPX</search:dotfileextension><search:size>68076</search:size>
<search:hithighlightedsummary> SIMILAR TO THE INFORMATION I WANT, COULD BE OPTION 2 </search:hithighlightedsummary>
</item>
这是我现在拥有的:
var feeds = from feed in xdoc.Descendants("item")
select new RSSS
{
Site = "TOPS",
URL = url,
Title = feed.Element("title").Value,
Link = feed.Element("link").Value,
Description = feed.Element("description").Value
};
按预期返回“描述”:
<div style="margin-top:5px"><link rel="stylesheet" type="text/css" href="confidential" />
<span class="srch-Icon"><a href="confidential" title="Operations Applications - MDI Diagnostics">
<img src="confidential" alt="Web Page" border="0" /></a></span>
<span class="psrch-Description"> THE INFORMATION I WANT</span>
<p class="srch-Metadata"><span class="srch-URL">
<a href="confidential" title="Operations Applications - MDI Diagnostics">confidential link</a>
-
66KB
</span></p></div>
那么,我如何具体访问“span class= psrch-Description”之间的信息,同时仍然能够访问链接和标题等?
**因为我不是在寻找类似的东西
var feeds = from feed in xDoc.Descendants("Show")
where (string)feed.Attribute("Code") == "456"
select new
{
EventDate = feed.Attribute("Date").Value
};
这不允许我获取其他信息。
【问题讨论】: