stuff-from-scratch/src/base/core/serialization/xml/XmlWriter.cpp
2023-12-27 12:20:02 +00:00

23 lines
551 B
C++

#include "XmlWriter.h"
#include "XmlDocument.h"
#include "XmlAttribute.h"
Status XmlWriter::toString(XmlDocument* document, String& output)
{
if (auto prolog = document->getProlog())
{
output += "<?xml";
for (const auto& [key, attribute] : prolog->getAttributes())
{
output += _s(" ") + attribute->getName() + _s("=\"") + attribute->getValue() + _s("\"");
}
output += "?>\n";
}
if (auto root = document->getRoot())
{
output += root->toString();
}
return {};
}