DenoDDeno
Powered by
bebrawB
Denoβ€’3y agoβ€’
3 replies
bebraw

Parsing HTML/XML

Lately I've been researching how to write a simple HTML/XML -> JSON converter. My syntax isn't completely standard HTML (i.e.,
<Button>
<Button>
is possible) which makes this a notch harder than it probably should be. Here's an example of how things should work: https://github.com/gustwindjs/gustwind/blob/feat/html-prototype/html-to-breezewind/tests/element_test.ts .

The current implementation relies on https://deno.land/x/deno_dom but the problem is that it's losing information for
tagName
tagName
. I cannot use it to tell a
button
button
apart from a
Button
Button
as it's uppercasing the tag by default.

As an alternative, I looked into https://deno.land/x/xml but it's losing structural information due to its automatic grouping (i.e., it folds
div
div
s within a single array and loses their relative positioning so I cannot map the structure later on to match the original).

Any insight on the issue would be valuable. Maybe I have to fork either to add the missing functionality but I hope to avoid that.
GitHub
gustwind/html-to-breezewind/tests/element_test.ts at feat/html-prot...
πŸ³πŸ’¨ – Deno powered JSON oriented site generator. Contribute to gustwindjs/gustwind development by creating an account on GitHub.
gustwind/html-to-breezewind/tests/element_test.ts at feat/html-prot...
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

CHM parsing library for Deno
MatthewMMatthew / help
3mo ago
Generate jUnit XML file from Deno Tests
MqxMMqx / help
3y ago
Error parsing version requirement for dependency -- expected?
brlewisBbrlewis / help
2y ago
deno blog without html sanitization
capo_grecoCcapo_greco / help
4y ago