C# 提取HTML文本
我正在解决一个问题。我将提取som HTML文本并将其存储为锚对象。例如:C# 提取HTML文本,c#,html,C#,Html,我正在解决一个问题。我将提取som HTML文本并将其存储为锚对象。例如: <html> <head> <title>{dynamihead/}</title> </head> <body> {repeatinghtml} <p>{repeatinganchor1/}</p> <p>{repeatinganchor2/}</p> <p>{repeatinganch
<html>
<head>
<title>{dynamihead/}</title>
</head>
<body>
{repeatinghtml}
<p>{repeatinganchor1/}</p>
<p>{repeatinganchor2/}</p>
<p>{repeatinganchor3/}</p>
<p>{repeatinganchor4/}</p>
{/repeatinghtml}
</body>
</html>
{dynamihead/}
{repeatinghtml}
{repeatinganchor1/}
{repeatinganchor2/}
{repeatinganchor3/}
{repeatinganchor4/}
{/repeatinghtml}
我想提取{}锚。如果它是一个自终止的对象,我只想创建{dynamihead/}这个锚对象。但如果里面有我想提取的儿童锚链
{repeatinghtml}
<p>{repeatinganchor1/}</p>
<p>{repeatinganchor2/}</p>
<p>{repeatinganchor3/}</p>
<p>{repeatinganchor4/}</p>
{/repeatinghtml}
{repeatinghtml}
{repeatinganchor1/}
{repeatinganchor2/}
{repeatinganchor3/}
{repeatinganchor4/}
{/repeatinghtml}
我想提取所有的子锚点,并把在主锚点的集合。我已经定义了Anchor类,但是我不太擅长字符串处理,所以我很难提取我想要的文本。这是一个winform应用程序,它将加载一个模板hmlt文件,处理它并将信息插入ancours,然后发送一封电子邮件i html格式。尝试查看库。即使乍一看它看起来更简单,也有一个字符串操作,而第十八个字符串操作可能还不够。我认为您可以使用正则表达式来提取字符串或XDocument。我曾尝试使用Htmlagibility库,但运气不佳。也许我用错了,但我尝试了一些没有运气的例子。