[gnote] Add function sharp::xml_node_content
- From: Aurimas Äernius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Add function sharp::xml_node_content
- Date: Sat, 11 Feb 2012 19:06:21 +0000 (UTC)
commit ead3338d2aa7d6e64de4687b5444759764312cd7
Author: Aurimas Äernius <aurisc4 gmail com>
Date: Sat Feb 11 20:56:51 2012 +0200
Add function sharp::xml_node_content
A function to get xmlNode content.
src/sharp/xml.cpp | 16 ++++++++++++++++
src/sharp/xml.hpp | 2 ++
2 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/sharp/xml.cpp b/src/sharp/xml.cpp
index 531f6d9..ac052cb 100644
--- a/src/sharp/xml.cpp
+++ b/src/sharp/xml.cpp
@@ -109,6 +109,22 @@ namespace sharp {
}
+ std::string xml_node_content(xmlNodePtr node)
+ {
+ if(!node) {
+ return "";
+ }
+ if(node->type == XML_ATTRIBUTE_NODE) {
+ node = xmlGetLastChild(node);
+ if(!node) {
+ return "";
+ }
+ }
+ char *res = reinterpret_cast<char*>(XML_GET_CONTENT(node));
+ return res ? res : "";
+ }
+
+
std::string xml_node_get_attribute(const xmlNodePtr node,
const char * attr_name)
{
diff --git a/src/sharp/xml.hpp b/src/sharp/xml.hpp
index 1ac6dfe..4568ed9 100644
--- a/src/sharp/xml.hpp
+++ b/src/sharp/xml.hpp
@@ -48,6 +48,8 @@ namespace sharp {
xmlNodePtr xml_node_xpath_find_single_node(const xmlNodePtr node,
const char * xpath);
+ std::string xml_node_content(xmlNodePtr node);
+
std::string xml_node_get_attribute(const xmlNodePtr node,
const char * attr_name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]