From 55edfb4006e7d01c520613f733b2b2bcfc6917d9 Mon Sep 17 00:00:00 2001 From: Richard Schwarting Date: Sat, 23 Jul 2011 16:56:22 -0400 Subject: [PATCH] * change content_to_string () to a content property, for user convenience. --- gxml/Element.vala | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/gxml/Element.vala b/gxml/Element.vala index 2a256e27..0f0a2063 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 {{{Eeylops Owl EmporiumObscurus Books}}} 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 + // * 'Eeylops Owl EmporiumObscurus Books' + // * + // * @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 {{{Eeylops Owl EmporiumObscurus Books}}} 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 + * 'Eeylops Owl EmporiumObscurus Books' + */ + // 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); + } + } } } -- GitLab