【发布时间】:2016-10-14 22:37:14
【问题描述】:
我想用它的代码替换 html 字符串中的 JQuery script 标记。意味着将src 属性设置为例如“scripts/jquery-1.9.1.js”的script 标记删除到包含当前JQuery 源代码的script 标记。
我使用此代码创建了一个新节点:
HtmlNode node = new HtmlNode(HtmlNodeType.Element, htmlDocument, index);
node.Name = "script";
node.PrependChild(HtmlNode.CreateNode(jQuerySourceCodeString));
无论我对jQuerySourceCodeString 做什么,它总是被截断为:
<script>/*!
* jQuery JavaScript Library v1.9.1
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
*
* Copyright 2005, 2012 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2013-2-4
*/
(function( window, undefined ) {
// Can't do this because several apps including ASP.NET trace
// the stack via arguments.caller.callee and Firefox dies if
// you try to trace through "use strict" call chains. (#13335)
// Support: Firefox 18+
//"use strict";
var
// The deferred used on DOM ready
readyList,
// A central reference to the root jQuery(document)
rootjQuery,
// Support: IE</script>
这显然不是我们能找到的代码here
我做错了什么?
更新:
1 - 我无法使用 InnerHtml,因为它试图将其读取为 html。
2 - HtmlNode.CreateNode 方法在找到这个“
【问题讨论】:
标签: c# html html-agility-pack