사용하여 XML 선언을 깰 :OptionWriteEmptyNodes 여기에 내가 가지고있는 슈퍼 간단한 코드가 HtmlAgilityPack
HtmlDocument htmlDoc = new HtmlDocument();
htmlDoc.OptionWriteEmptyNodes = true;
htmlDoc.Load("sourcefilepath");
htmlDoc.Save("destfilepath", Encoding.UTF8);
입력 :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/>
<link rel="stylesheet" href="main.css" type="text/css"/>
</head>
<body>lots of text here, obviously not relevant to this problem</body>
</html>
출력 :
<?xml version="1.0" encoding="UTF-8" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<link rel="stylesheet" href="main.css" type="text/css" />
</head>
<body>lots of text here, obviously not relevant to this problem</body>
</html>
당신은 처음에 저를 볼 수 있습니다 거기에 오류가 있습니다 : /> 대신?> 이것은 OptionWriteEmptyNodes를 true로 설정하면 발생합니다. 값. 그렇지 않으면 메타/링크 태그 (및 문서 본문의 다른 태그)가 닫히지 않기 때문에 true로 설정되었습니다.
누구나 해결 방법을 알고 계십니까?
감사합니다,이 해결 방법으로 좋아 보이고 있습니다. 그 동안에도 아직 해결책이 없어도 codeplex 포럼에서이 문제가 발견되었지만 곧 수정 될 것입니다. – Alex