0.2.3 • Published 8 years ago

dom2json v0.2.3

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

dom2json

This converts DOM documents to JSON. It was intended to be used for XML and now made to be generic to accomodate HTML documents as well.

Build Status Coverage Status npm version bitHound Overall Score

Example

let xml = dp.parseFromString(`<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  <Hello one="1" two="2" three="3"><Hi class="a"><h1>Hello World</h1></Hi><Hi class="a">Hello again</Hi></Hello>`, 'text/xml')
result = dom2json(xml)

Results:

{
  "document":{
    "Hello":{
      "Hi":[
        {
          "h1":[
            {
              "$attrs": {
              },
              "$textContent": "Hello World"
            }
          ],
          "$attrs":{
            "class": "a"
          },
          "$textContent": "Hello World"
        },
        {
          "$attrs":{
            "class": "a"
          },
          "$textContent": "Hello again"
        }
      ],
      "$attrs":{
        "one":"1",
        "two":"2",
        "three":"3"
      }
    }
  }
}
0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago