我只需要显示CDATA(XDocument)内容中的图像。 C#mvc [英] I need to display only the image from the CDATA (XDocument) content. C# mvc

查看:50
本文介绍了我只需要显示CDATA(XDocument)内容中的图像。 C#mvc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。

我有一个文件xml rss和foreach项目描述:





/ /查询XML RSS数据中的< item>并将每一个选择为新帖子()

hi all.
I have a file xml rss and foreach item decription :


// Query the <item>s in the XML RSS data and select each one into a new Post()

XDocument xDoc = XDocument.Load("http://vnexpress.net/rss/tin-moi-nhat.rss");
IEnumerable<Bus_24h> posts =
    from post in xDoc.Descendants("item")
    select new Bus_24h(post);

// Print each post to the console
foreach (var post in posts)
{
    Bus_24h tin = new Bus_24h();
    tin.Description = post.Description;
    //tin.iml_url= ???? ( <description><![CDATA[<a href="http://sohoa.vnexpress.net/tin-tuc/cong-dong/blog/nhung-tieu-chi-de-dien-thoai-viet-thanh-cong-3269249.html"><img width=130 height=100 src="http://c1.f5.img.vnecdn.net/2015/08/25/phone-1-4120-1440474313_180x108.jpg" ></a>Thị trường điện thoại luôn năng động, muốn thu hút người tiêu dùng là điều khá khó cho những nhà sản xuất mới. Vậy lý do gì khiến tôi chọn sản phẩm của bạn?</description> )
    tin.Link = post.Link;
    tin.PublishDate = post.PublishDate;
    tin.title = post.title;
    list.Add(tin);
}





我不能设置tin.iml_url = scr img_url

我想获取价值标签img查看图片。



请帮助我,非常感谢。



I can not set tin.iml_url=scr img_url
I want to get value tag img for view Image.

please help Me, thank so much.

推荐答案

如果我理解你,你必须解析html文本才能从< img src =获得图像源... > 标签。



开始的好点:如何使用C#解析HTML [ ^ ]



另一种方法是使用Regex [ ^ ]类。

怎么做我用正则表达式提取HTML img源? [ ^ ]
If i understand you well, you have to parse html text to be able to get image source from <img src="..."> tag.

Good point to start: How to Parse HTML using C# [^]

Another way is to use Regex[^] class.
How do I extract HTML img sources with a regular expression?[^]


这篇关于我只需要显示CDATA(XDocument)内容中的图像。 C#mvc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆