Document& Document::read(const std::string& filename){ pugi::xml_parse_result result = doc_()->load_file( filename.c_str(), // See above for options used here (pugi::parse_default | pugi::parse_ws_pcdata) ); if(not result){ STENCILA_THROW(Exception,result.description()); } return *this; }
Document& Document::load(const std::string& xml){ // The`pugi::parse_ws_pcdata` option prevents whitespace only text // nodes from being discarded. // See http://pugixml.googlecode.com/svn/trunk/docs/manual/loading.html#manual.loading.options pugi::xml_parse_result result = doc_()->load_string( xml.c_str(), (pugi::parse_default | pugi::parse_ws_pcdata) ); if(not result){ STENCILA_THROW(Exception,result.description()); } return *this; }
xmlNodePtr GetXmlNodePtrFromString( const string& xml_string ) { xmlNodePtr root_node = 0; Xml::DocPtr doc_( xmlParseDoc( BAD_CAST xml_string.c_str() ) ); if ( doc_ ) { root_node = xmlDocGetRootElement( doc_ ); } if ( root_node ) { return xmlCopyNode( root_node, 1 ); } return 0; }
Node Document::doctype(const std::string& type){ pugi::xml_node doctype = doc_()->prepend_child(pugi::node_doctype); doctype.set_value(type.c_str()); return doctype; }