print_xml

This commit is contained in:
David Rose 2012-01-01 02:39:36 +00:00
parent ebc948b3f8
commit bbdd1341d8
2 changed files with 31 additions and 0 deletions

View File

@ -14,6 +14,7 @@
#include "config_dxml.h"
#include "dconfig.h"
#include <stdio.h>
BEGIN_PUBLISH
#include "tinyxml.h"
@ -72,3 +73,30 @@ write_xml_stream(ostream &out, TiXmlDocument *doc) {
out << *doc;
}
END_PUBLISH
BEGIN_PUBLISH
////////////////////////////////////////////////////////////////////
// Function: print_xml
// Description: Writes an XML object to stdout, with formatting.
////////////////////////////////////////////////////////////////////
void
print_xml(TiXmlNode *xnode) {
xnode->Print(stdout, 0);
}
END_PUBLISH
BEGIN_PUBLISH
////////////////////////////////////////////////////////////////////
// Function: print_xml_to_file
// Description: Writes an XML object to the indicated file, with
// formatting. Unfortunately the VFS cannot be
// supported; the file must be a real filename on disk.
////////////////////////////////////////////////////////////////////
void
print_xml_to_file(const Filename &filename, TiXmlNode *xnode) {
string os_name = filename.to_os_specific();
FILE *file = fopen(os_name.c_str(), "w");
xnode->Print(file, 0);
fclose(file);
}
END_PUBLISH

View File

@ -34,9 +34,12 @@ NotifyCategoryDecl(dxml, EXPCL_PANDA, EXPTP_PANDA);
extern EXPCL_PANDA void init_libdxml();
class TiXmlDocument;
class TiXmlNode;
BEGIN_PUBLISH
TiXmlDocument *read_xml_stream(istream &in);
void write_xml_stream(ostream &out, TiXmlDocument *doc);
void print_xml(TiXmlNode *xnode);
void print_xml_to_file(const Filename &filename, TiXmlNode *xnode);
END_PUBLISH
#endif