From 7e7153457722ff2272bf094cca5387bd2e2ebd71 Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine@gmail.com" Date: Sun, 29 Apr 2012 22:51:21 +0000 Subject: docs: Regenerated HTML documentation git-svn-id: http://pugixml.googlecode.com/svn/trunk@908 99668b35-9821-0410-8761-19e4c4f06640 --- docs/manual/modify.html | 90 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 5 deletions(-) (limited to 'docs/manual/modify.html') diff --git a/docs/manual/modify.html b/docs/manual/modify.html index 3db02e1..b039dc7 100644 --- a/docs/manual/modify.html +++ b/docs/manual/modify.html @@ -4,15 +4,15 @@ Modifying document data - - + +
-pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: @@ -35,6 +35,7 @@
Setting attribute data
Adding nodes/attributes
Removing nodes/attributes
+
Working with text contents
Cloning nodes/attributes

@@ -406,6 +407,85 @@

+

+ pugixml provides a special class, xml_text, + to work with text contents stored as a value of some node, i.e. <node><description>This is a node</description></node>. + Working with text objects to retrieve data is described in the + documentation for accessing document data; this section describes + the modification interface of xml_text. +

+

+ Once you have an xml_text + object, you can set the text contents using the following function: +

+
bool xml_text::set(const char_t* rhs);
+
+

+ This function tries to set the contents to the specified string, and returns + the operation result. The operation fails if the text object was retrieved + from a node that can not have a value and that is not an element node (i.e. + it is a node_declaration node), if + the text object is empty, or if there is insufficient memory to handle the + request. The provided string is copied into document managed memory and can + be destroyed after the function returns (for example, you can safely pass + stack-allocated buffers to this function). Note that if the text object was + retrieved from an element node, this function creates the PCDATA child node + if necessary (i.e. if the element node does not have a PCDATA/CDATA child + already). +

+

+ In addition to a string function, several functions are provided for handling + text with numbers and booleans as contents: +

+
bool xml_text::set(int rhs);
+bool xml_text::set(unsigned int rhs);
+bool xml_text::set(double rhs);
+bool xml_text::set(bool rhs);
+
+

+ The above functions convert the argument to string and then call the base + set function. These functions + have the same semantics as similar xml_attribute + functions. You can refer to documentation + for the attribute functions for details. +

+

+ For convenience, all set + functions have the corresponding assignment operators: +

+
xml_text& xml_text::operator=(const char_t* rhs);
+xml_text& xml_text::operator=(int rhs);
+xml_text& xml_text::operator=(unsigned int rhs);
+xml_text& xml_text::operator=(double rhs);
+xml_text& xml_text::operator=(bool rhs);
+
+

+ These operators simply call the right set + function and return the attribute they're called on; the return value of + set is ignored, so errors + are ignored. +

+

+ This is an example of using xml_text + object to modify text contents (samples/text.cpp): +

+

+ +

+
// change project version
+project.child("version").text() = 1.2;
+
+// add description element and set the contents
+// note that we do not have to explicitly add the node_pcdata child
+project.append_child("description").text().set("a test project");
+
+

+

+
+
+

@@ -528,7 +608,7 @@

- @@ -536,7 +616,7 @@
-pugixml 1.0 manual | +pugixml 1.2 manual | Overview | Installation | Document: -- cgit v1.2.3