我想通过指定的模板解析源文件中的值。
让我说:
模板:
<div>{value}</div>
<span id="id1">{value}</span>
<div><span>{value}</span></div>
源文件:
<h1>The source file can have other parts but will contain the specified template structure</h1>
<div>value 1</div>
<span id="id1">value 2</span>
<div>or a bit more complex content...<span>value 3</span><a>abc</a></div>
<h2>other file content again</h2>
期望的输出是一个数组:[值1,值2,值3 ]
有人知道为此目的使用NodeJS模块吗?
谢谢!
答案 0 :(得分:0)
似乎没有lib用于此目的。 我有另一种解决方案,所以我有自己的解决方案,所以问题应该是:如何解析Web内容。 答案是:我们可以使用xpath作为此处讨论的内容:Performant parsing of pages with Node.js and XPath