From 35a201cc8ef0c3f5b2df88d2e528aabee1048348 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Fri, 30 Apr 2021 18:47:09 +0200 Subject: Initial/Final commit --- libxml2-2.9.10/doc/tutorial/ar01s06.html | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 libxml2-2.9.10/doc/tutorial/ar01s06.html (limited to 'libxml2-2.9.10/doc/tutorial/ar01s06.html') diff --git a/libxml2-2.9.10/doc/tutorial/ar01s06.html b/libxml2-2.9.10/doc/tutorial/ar01s06.html new file mode 100644 index 0000000..c09e6ef --- /dev/null +++ b/libxml2-2.9.10/doc/tutorial/ar01s06.html @@ -0,0 +1,35 @@ +Writing element content

Writing element content

+ Writing element content uses many of the same steps we used above + — parsing the document and walking the tree. We parse the document, + then traverse the tree to find the place we want to insert our element. For + this example, we want to again find the "storyinfo" element and + this time insert a keyword. Then we'll write the file to disk. Full code: + Appendix E, Code for Add Keyword Example

+ The main difference in this example is in + parseStory: + +

+void
+parseStory (xmlDocPtr doc, xmlNodePtr cur, char *keyword) {
+
+	1 xmlNewTextChild (cur, NULL, "keyword", keyword);
+    return;
+}
+      

+

1

The xmlNewTextChild + function adds a new child element at the + current node pointer's location in the + tree, specified by cur.

+

+ + Once the node has been added, we would like to write the document to + file. Is you want the element to have a namespace, you can add it here as + well. In our case, the namespace is NULL. +

+	xmlSaveFormatFile (docname, doc, 1);
+      

+ The first parameter is the name of the file to be written. You'll notice + it is the same as the file we just read. In this case, we just write over + the old file. The second parameter is a pointer to the xmlDoc + structure. Setting the third parameter equal to one ensures indenting on output. +

-- cgit v1.2.3