Skip to content

Commit

Permalink
modernize & improve the example in readme.md (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
brodybits committed Jul 1, 2020
1 parent 84eb68c commit a35ef49
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,22 @@ Install:
Example:
====
```javascript
var DOMParser = require('xmldom').DOMParser;
var doc = new DOMParser().parseFromString(
'<xml xmlns="a" xmlns:c="./lite">\n'+
'\t<child>test</child>\n'+
'\t<child></child>\n'+
'\t<child/>\n'+
'</xml>'
,'text/xml');
doc.documentElement.setAttribute('x','y');
doc.documentElement.setAttributeNS('./lite','c:x','y2');
var nsAttr = doc.documentElement.getAttributeNS('./lite','x')
console.info(nsAttr)
const { DOMParser } = require('xmldom')

const doc = new DOMParser().parseFromString(
'<xml xmlns="a" xmlns:c="./lite">\n' +
'\t<child>test</child>\n' +
'\t<child></child>\n' +
'\t<child/>\n' +
'</xml>',
'text/xml'
)
doc.documentElement.setAttribute('x', 'y')
doc.documentElement.setAttributeNS('./lite', 'c:x', 'y2')
console.info(doc)

const nsAttr = doc.documentElement.getAttributeNS('./lite', 'x')
console.info(nsAttr)
```
API Reference
=====
Expand Down

0 comments on commit a35ef49

Please sign in to comment.