XML/DOM serialization: Difference between revisions

Added FreeBASIC
m (→‎{{header|Wren}}: Changed to Wren S/H)
(Added FreeBASIC)
 
Line 820:
 
(On the use of <tt>&lt;unsafe></tt>: The class has not yet been reviewed for E safety, so <tt>&lt;import:...makeDocumentBuilderFactory></tt> is not yet allowed. The review would probably be straightforward.)
 
=={{header|FreeBASIC}}==
{{libheader|libxml2}}
<syntaxhighlight lang="vbnet">#include once "crt/stdio.bi"
#include once "crt/stdlib.bi"
#include once "libxml/tree.bi"
#include once "libxml/parser.bi"
 
'' Create a new document
Dim As xmlDocPtr doc = xmlNewDoc(Strptr("1.0"))
 
'' Create a root node
Dim As xmlNodePtr root_node = xmlNewNode(NULL, Strptr("root"))
 
'' Set the root node for the document
xmlDocSetRootElement(doc, root_node)
 
'' Create a new node
Dim As xmlNodePtr node = xmlNewNode(NULL, Strptr("element"))
 
'' Add some text to the node
xmlNodeSetContent(node, Strptr("Some text here"))
 
'' Add the new node to the root node
xmlAddChild(root_node, node)
 
'' Dump the document to stdout, it will be well formatted
xmlDocDump(stdout, doc)
 
'' Free the document
xmlFreeDoc(doc)
 
'' Free the global variables that may have been allocated by the parser
xmlCleanupParser()</syntaxhighlight>
 
=={{header|F_Sharp|F#}}==
2,130

edits