Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cleanup CDATA example

  • Loading branch information...
commit 88a633cdb4b9d5096c921b01263d603a9544ca38 1 parent 76696fa
@defunctzombie defunctzombie authored
Showing with 15 additions and 14 deletions.
  1. +15 −14 README.md
View
29 README.md
@@ -26,24 +26,25 @@ var child = children[0];
console.log(child.attr('foo').value()); // prints "bar"
```
-CDATA Example by Dudochkin Victor <blacksmith@gogoo.ru>:
+CDATA Example:
- var util = require('util');
- var libxml = require('libxmljs');
+```javascript
+var libxml = require('libxmljs');
- var doc = libxml.Document();
- var elem = doc.node('name1');
- var newChild = libxml.Element(doc, 'new-child');
- elem.addChild(newChild);
+var doc = libxml.Document();
+var elem = doc.node('name1');
+var newChild = libxml.Element(doc, 'new-child');
+elem.addChild(newChild);
+var child1 = elem.node('child1');
+var child2 = elem.node('child2', 'second');
+var newChild = libxml.Element(doc, 'new-child');
+var name2 = elem.node('name2');
+name2.addChild(newChild);
+child2.cdata('<h1>cdata test</h1>').cdata('<p>It\'s worked</p>').cdata('<hr/>All done');
- var child1 = elem.node('child1');
- var child2 = elem.node('child2', 'second');
- var newChild = libxml.Element(doc, 'new-child');
- var name2 = elem.node('name2');
- name2.addChild(newChild);
- child2.cdata('<h1>cdata test</h1>').cdata('<p>It\'s worked</p>').cdata('<hr/>All done');
- util.puts('Document With CDATA: ' + doc.toString());
+console.log('Document with CDATA: %s', doc.toString());
+```
## Basics
Please sign in to comment.
Something went wrong with that request. Please try again.