gpt4 book ai didi

c# - 如何以编程方式更改 C# 中 HTML 文件的 CSS 链接?

转载 作者:太空宇宙 更新时间:2023-11-04 15:36:11 24 4
gpt4 key购买 nike

我有一个带有以下标记的 HTML 文档:

<LINK REL="STYLESHEET" HREF="c87d971ab8bc48ee87f9ced1b1d5c6e2.css" CHARSET="ISO-8859-1" TYPE="text/css">

我想要一个 C# 中的解决方案,它将 CSS 更改为(CSS 文件名每次都更改):

<LINK REL="STYLESHEET" HREF="other.css" CHARSET="ISO-8859-1" TYPE="text/css">

我如何在 C# 中执行此操作?

最佳答案

您应该查看 Html Agility Pack :

What is exactly the Html Agility Pack (HAP)?

This is an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor XSLT to use it, don't worry...). It is a .NET code library that allows you to parse "out of the web" HTML files. The parser is very tolerant with "real world" malformed HTML. The object model is very similar to what proposes System.Xml, but for HTML documents (or streams).

(引自他们的 codeplex 页面)

关于c# - 如何以编程方式更改 C# 中 HTML 文件的 CSS 链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8592058/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com