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/ar01s07.html | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 libxml2-2.9.10/doc/tutorial/ar01s07.html (limited to 'libxml2-2.9.10/doc/tutorial/ar01s07.html') diff --git a/libxml2-2.9.10/doc/tutorial/ar01s07.html b/libxml2-2.9.10/doc/tutorial/ar01s07.html new file mode 100644 index 0000000..fd5c4dd --- /dev/null +++ b/libxml2-2.9.10/doc/tutorial/ar01s07.html @@ -0,0 +1,30 @@ +Writing Attribute

Writing Attribute

+Writing an attribute is similar to writing text to a new element. In + this case, we'll add a reference URI to our + document. Full code:Appendix F, Code for Add Attribute Example.

+ A reference is a child of the story + element, so finding the place to put our new element and attribute is + simple. As soon as we do the error-checking test in our + parseDoc, we are in the right spot to add our + element. But before we do that, we need to make a declaration using a + data type we have not seen yet: +

+	xmlAttrPtr newattr;
+      

+ We also need an extra xmlNodePtr: +

+	xmlNodePtr newnode;
+      

+

+ The rest of parseDoc is the same as before until we + check to see if our root element is story. If it is, + then we know we are at the right spot to add our element: + +

+	1 newnode = xmlNewTextChild (cur, NULL, "reference", NULL);
+	2 newattr = xmlNewProp (newnode, "uri", uri);	
+      

+

1

First we add a new node at the location of the current node + pointer, cur. using the xmlNewTextChild function.

+

Once the node is added, the file is written to disk just as in the + previous example in which we added an element with text content.

-- cgit v1.2.3