本文介绍了在解析HTML敏捷包问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个简单的字符串:
I have this simple string:
string testString = "6/21 <span style='font-size: x-small; font-family: Arial'><span style='font-size: 10pt; font-family: Arial'>Just got 78th street</span></span>";
如何使用HTML敏捷包解析出只是文本。
how do i use the html agility pack to parse out just the text.
请注意:有嵌套在另一个里面跨度跨度
please note: there is a span nested inside another span.
谢谢,
棒。
推荐答案
我觉得 InnertText
属性应该给予只是文本 -
I think the InnertText
property should give just the text -
var testString = "6/21 <span style='font-size: x-small; font-family: Arial'><span style='font-size: 10pt; font-family: Arial'>Just got 78th street</span></span>";
var doc = new HtmlDocument();
doc.LoadHtml(testString);
var justTheText = doc.DocumentNode.InnerText;
这code将返回 -
This code will return -
6/21 Just got 78th street
这是你想要的吗?
Is that what you wanted?
这篇关于在解析HTML敏捷包问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!