Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Commit

Permalink
clean up extra namespaces when extracting XML content from Atom feed (f…
Browse files Browse the repository at this point in the history
…ixes #147).
  • Loading branch information
akrennmair committed Feb 18, 2015
1 parent 276a977 commit c7f4c74
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions rss/rss_parser.cpp
Expand Up @@ -21,10 +21,19 @@ std::string rss_parser::get_content(xmlNode * node) {
return retval;
}

void rss_parser::cleanup_namespaces(xmlNodePtr node) {
node->ns = NULL;
for (auto ptr = node->children; ptr != NULL; ptr = ptr->next) {
cleanup_namespaces(ptr);
}
}

std::string rss_parser::get_xml_content(xmlNode * node) {
xmlBufferPtr buf = xmlBufferCreate();
std::string result;

cleanup_namespaces(node);

if (node->children) {
for (xmlNodePtr ptr = node->children; ptr != NULL; ptr = ptr->next) {
if (xmlNodeDump(buf, doc, ptr, 0, 0) >= 0) {
Expand Down
1 change: 1 addition & 0 deletions rss/rsspp_internal.h
Expand Up @@ -29,6 +29,7 @@ struct rss_parser {
protected:
std::string get_content(xmlNode * node);
std::string get_xml_content(xmlNode * node);
void cleanup_namespaces(xmlNodePtr node);
std::string get_prop(xmlNode * node, const char * prop, const char * ns = NULL);
std::string w3cdtf_to_rfc822(const std::string& w3cdtf);
bool node_is(xmlNode * node, const char * name, const char * ns_uri = NULL);
Expand Down

0 comments on commit c7f4c74

Please sign in to comment.