File: document_create.js

package info (click to toggle)
gxml 0.20.4%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,364 kB
  • sloc: xml: 131,277; ansic: 786; javascript: 328; python: 88; makefile: 35; sh: 11
file content (25 lines) | stat: -rwxr-xr-x 829 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/gjs

const GXml = imports.gi.GXml;

let doc = GXml.GomDocument.new ();

/* <book></book> */
let elem = doc.create_element ("book");
print ("Book element: " + elem.write_string ());

/* <book>Between the book tags is text!</book> */
let text = doc.create_text_node ("Between the book tags is text!");
print ("Text: " + text.data);

/* <book><!-- comment: I really like this book -->The fault in our stars</book> */
let comment = doc.create_comment ("comment: I really like this book");
print ("Comment: " + comment.data);

/* <?xml href="style.xsl" type="text/xml"?> */
let pi = doc.create_processing_instruction ("xml", "href=\"style.xsl\" type=\"text/xml\"");
print ("Processing Instruction: " + pi.data);

/* <element id=""> */
elem.set_attribute ("id", "001");
print ("Attribute id: " + elem.get_attribute ("id"));