summaryrefslogtreecommitdiff
path: root/src/core/XML.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/XML.cpp')
-rw-r--r--src/core/XML.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/XML.cpp b/src/core/XML.cpp
index ad69ba1..038cb86 100644
--- a/src/core/XML.cpp
+++ b/src/core/XML.cpp
@@ -4,7 +4,12 @@
namespace ousia {
namespace xml {
-void Element::serialize(std::ostream& out, unsigned int tabdepth)
+void Node::serialize(std::ostream& out){
+ out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ doSerialize(out, 0);
+}
+
+void Element::doSerialize(std::ostream& out, unsigned int tabdepth)
{
for (unsigned int t = 0; t < tabdepth; t++) {
out << '\t';
@@ -15,7 +20,7 @@ void Element::serialize(std::ostream& out, unsigned int tabdepth)
}
out << ">\n";
for (auto &n : children) {
- n->serialize(out, tabdepth + 1);
+ n->doSerialize(out, tabdepth + 1);
}
for (unsigned int t = 0; t < tabdepth; t++) {
out << '\t';
@@ -23,7 +28,7 @@ void Element::serialize(std::ostream& out, unsigned int tabdepth)
out << "</" << name << ">\n";
}
-void Text::serialize(std::ostream& out, unsigned int tabdepth)
+void Text::doSerialize(std::ostream& out, unsigned int tabdepth)
{
for (unsigned int t = 0; t < tabdepth; t++) {
out << '\t';