cheerio
下此代码的输出:
<div id="some"></div>
返回为自结束标记:
<div id="some"/>
有可能改变这种行为(自动关闭)吗?我不想使用它。
我尝试了这些选项,但似乎不影响输出:
{ decodeEntities: false, xmlMode: true, recognizeSelfClosing: false },
是否有其他解决方案可用?
import "./styles.css";
import { CheerioAPI, load } from "cheerio";
console.clear();
const doc = load(
`
<div id="some"></div>
`,
{ decodeEntities: false, xmlMode: true, recognizeSelfClosing: false },
false
);
console.log({
after: doc.html({
decodeEntities: false,
xmlMode: true,
recognizeSelfClosing: false
})
});
1条答案
按热度按时间6mzjoqzu1#
您已设置
xmlMode:true
,需要设置xmlMode:false
并删除recognizeSelfClosing: false
这将在控制台中给予如下输出