-
-
Notifications
You must be signed in to change notification settings - Fork 106
XML Prolog
Ozgur Ozcitak edited this page Dec 24, 2013
·
10 revisions
The XML prolog is usually created with the create
method.
var root = require('xmlbuilder').create('xbel',
{version: '1.0', encoding: 'UTF-8'},
{pubid: '+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML',
sysid: 'http://www.python.org/topics/xml/dtds/xbel-1.0.dtd'
}
);
The resulting XML will be:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xbel PUBLIC "+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML"
"http://www.python.org/topics/xml/dtds/xbel-1.0.dtd">
<xbel/>
The XML declaration can also be created at a later time by calling declaration
from anywhere in the document (can also be abbreviated to dec
).
builder.create('root')
.dec('1.0', 'UTF-8', true)
.ele('node');
The resulting XML will be:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<node/>
</root>
The dec
method will return the root node.
The DTD can also be created at a later time by calling doctype
from anywhere in the document (can also be abbreviated to dtd
).
builder.create('xbel')
.dtd('+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML',
'http://www.python.org/topics/xml/dtds/xbel-1.0.dtd')
.com('internal subset')
.ele('title', '(#PCDATA)')
.up()
.ele('metadata');
The resulting XML will be:
<?xml version="1.0"?>
<!DOCTYPE xbel PUBLIC "+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML"
"http://www.python.org/topics/xml/dtds/xbel-1.0.dtd" [
<!-- internal subset -->
<!ELEMENT title (#PCDATA)>
]>
<xbel>
<metadata/>
</xbel>
The dtd
method will return the DTD object.