mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-15 04:07:17 +01:00
4a6bfc086c
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
//
|
|
// DOMWriter.cpp
|
|
//
|
|
// This sample demonstrates the DOMWriter class and how to
|
|
// build DOM documents in memory.
|
|
//
|
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
|
// and Contributors.
|
|
//
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
//
|
|
|
|
|
|
#include "Poco/DOM/Document.h"
|
|
#include "Poco/DOM/Element.h"
|
|
#include "Poco/DOM/Text.h"
|
|
#include "Poco/DOM/AutoPtr.h"
|
|
#include "Poco/DOM/DOMWriter.h"
|
|
#include "Poco/XML/XMLWriter.h"
|
|
#include <iostream>
|
|
|
|
|
|
using Poco::XML::Document;
|
|
using Poco::XML::Element;
|
|
using Poco::XML::Text;
|
|
using Poco::XML::AutoPtr;
|
|
using Poco::XML::DOMWriter;
|
|
using Poco::XML::XMLWriter;
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
// build a DOM document and write it to standard output.
|
|
|
|
AutoPtr<Document> pDoc = new Document;
|
|
|
|
AutoPtr<Element> pRoot = pDoc->createElement("root");
|
|
pDoc->appendChild(pRoot);
|
|
|
|
AutoPtr<Element> pChild1 = pDoc->createElement("child1");
|
|
AutoPtr<Text> pText1 = pDoc->createTextNode("text1");
|
|
pChild1->appendChild(pText1);
|
|
pRoot->appendChild(pChild1);
|
|
|
|
AutoPtr<Element> pChild2 = pDoc->createElement("child2");
|
|
AutoPtr<Text> pText2 = pDoc->createTextNode("text2");
|
|
pChild2->appendChild(pText2);
|
|
pRoot->appendChild(pChild2);
|
|
|
|
DOMWriter writer;
|
|
writer.setNewLine("\n");
|
|
writer.setOptions(XMLWriter::PRETTY_PRINT);
|
|
writer.writeNode(std::cout, pDoc);
|
|
|
|
return 0;
|
|
}
|