From a45e4307d377da9fbd17890a3701b443eef5b94e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 22 Apr 2018 21:52:32 +0100 Subject: [PATCH] Make Node::content ignore comments and CDATA. --- src/cxml.cc | 2 +- src/cxml.h | 2 +- test/ref/a.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cxml.cc b/src/cxml.cc index 77770f9..3c2eda2 100644 --- a/src/cxml.cc +++ b/src/cxml.cc @@ -220,7 +220,7 @@ cxml::Node::content () const xmlpp::Node::NodeList c = _node->get_children (); for (xmlpp::Node::NodeList::const_iterator i = c.begin(); i != c.end(); ++i) { xmlpp::ContentNode const * v = dynamic_cast (*i); - if (v) { + if (v && dynamic_cast(v)) { content += v->get_content (); } } diff --git a/src/cxml.h b/src/cxml.h index b7f1ef5..4d01eef 100644 --- a/src/cxml.h +++ b/src/cxml.h @@ -188,7 +188,7 @@ public: return n; } - /** @return The content of this node */ + /** @return The text content of this node (including comments or CDATA) */ std::string content () const; /** @return namespace URI of this node */ diff --git a/test/ref/a.xml b/test/ref/a.xml index e854aae..fa8901f 100644 --- a/test/ref/a.xml +++ b/test/ref/a.xml @@ -5,6 +5,6 @@ yes 1 2 - testingmore testing + testingmore testing jim -- 2.30.2