I'm attempting map HTML into JSON with structure intact. Are there any libraries out there that do this or will I need to write my own? I suppose if there are no html2json libraries out there I could take an xml2json library as a start. After all, html is only a variant of xml anyway right?
UPDATE: Okay, I should probably give an example. What I'm trying to do is the following. Parse a string of html:
<div>
<span>text</span>Text2
</div>
into a json object like so:
{
type : div,
content : [
{
type : span,
content : [
Text2
]
},
Text2
]
}
NOTE: In case you didn't notice the tag, I'm looking for a solution in Javascript