#include <Poco / DOM / Text.h>
#include <Poco / DOM / Element.h>
#include <Poco / DOM / Comment.h>
#include <Poco / DOM / ProcessingInstruction.h>
#include <Poco / DOM /Attr.h>
#include <Poco / DOM / Document.h>
#include <Poco / DOM / DOMWriter.h>
#include <Poco / XML / XMLWriter.h>
#include <Poco / AutoPtr.h>
#include < Poco / FileStream.h>
usando Poco :: AutoPtr;
int main ()
{
AutoPtr <Poco :: XML :: Documento> pDoc = new Poco :: :: Documento XML;
AutoPtr <Poco :: :: XML Elemento> Myroot = pDoc-> createElement ( "raíz");
AutoPtr <Poco :: :: XML Elemento> Mi hijo = pDoc-> createElement ( "niño");
AutoPtr <Poco :: XML ::
AutoPtr <Poco :: XML :: Texto> NameNode = pDoc-> createTextNode ( "my_name_is_xiaoqiang");
AutoPtr <Poco :: XML :: ProcessingInstruction> pi = pDoc-> createProcessingInstruction ( "xml", "version = '1.0' encoding = 'UTF-8'");
AutoPtr <Poco :: XML :: Comentario> comm = pDoc-> createComment ( "new_day");
myGrandChild-> appendChild (NameNode);
myChild-> appendChild (myGrandChild);
myRoot-> appendChild (Mi hijo);
pDoc-> appendChild (pi);
pDoc-> appendChild (comm);
pDoc-> appendChild (Myroot);
Poco :: XML :: DOMWriter escritura;
write.setOptions (Poco :: XML :: :: XMLWriter PRETTY_PRINT);
Poco OFS :: FileStream ( "./ example.txt", std :: ios :: en);
write.writeNode (OFS, PDOC);
return 0;
}
notas:
LIBS + = -lPocoFoundation -lPocoXML