[gxml] * change content_to_string () to a content property, for user convenience.
- From: Richard Hans Schwarting <rschwart src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] * change content_to_string () to a content property, for user convenience.
- Date: Sat, 23 Jul 2011 20:57:58 +0000 (UTC)
commit 55edfb4006e7d01c520613f733b2b2bcfc6917d9
Author: Richard Schwarting <aquarichy gmail com>
Date: Sat Jul 23 16:56:22 2011 -0400
* change content_to_string () to a content property, for user convenience.
gxml/Element.vala | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/gxml/Element.vala b/gxml/Element.vala
index 2a256e2..0f0a206 100644
--- a/gxml/Element.vala
+++ b/gxml/Element.vala
@@ -281,5 +281,51 @@ namespace GXml.Dom {
}
}
+
+ // /**
+ // * This is a convenience method for Elements, mostly
+ // * useful when you know a given element's children are
+ // * only Text. With the example {{{<shops><shop
+ // * id="1">Eeylops Owl Emporium</shop><shop
+ // * id="2">Obscurus Books</shop></shops>}}} taking the
+ // * node for the shop element with id 1 and using this
+ // * method, you would get back "Eeylops Owl Emporiums".
+ // * If you used it on the shops element, you'd get
+ // * '<shop id="1">Eeylops Owl Emporium</shop><shop
+ // * id="2">Obscurus Books</shop>'
+ // *
+ // * @return XML string of child contents
+ // */
+ // public string content_to_string () {
+ // return this.child_nodes.to_string (true);
+ // }
+
+ /**
+ * This is a convenience property for Elements, mostly
+ * useful when you know a given element's children are
+ * only Text. With the example {{{<shops><shop
+ * id="1">Eeylops Owl Emporium</shop><shop
+ * id="2">Obscurus Books</shop></shops>}}} taking the
+ * node for the shop element with id 1 and using this
+ * method, you would get back "Eeylops Owl Emporiums".
+ * If you used it on the shops element, you'd get
+ * '<shop id="1">Eeylops Owl Emporium</shop><shop
+ * id="2">Obscurus Books</shop>'
+ */
+ // TODO: add test
+ public string content {
+ owned get {
+ //return this.child_nodes.to_string (true);
+ return base.node->get_content ();
+ // TODO: what's the difference between this and stringifying
+ // the child nodes?
+ }
+ set {
+ // TODO: check impact on existing child nodes; they will be
+ // detached, right?
+ // TODO: is XML in value interpreted or escaped?
+ base.node->set_content (value);
+ }
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]