1 #include "../../include/freenet/introductionpuzzlexml.h"
\r
7 IntroductionPuzzleXML::IntroductionPuzzleXML()
\r
12 std::string IntroductionPuzzleXML::GetXML()
\r
14 Poco::AutoPtr<Poco::XML::Document> doc=new Poco::XML::Document;
\r
16 //TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8","");
\r
17 Poco::XML::Element *root=doc->createElement("IntroductionPuzzle");
\r
18 //TiXmlElement *tid;
\r
21 doc->appendChild(root);
\r
22 //td.LinkEndChild(tdec);
\r
23 //tid=new TiXmlElement("IntroductionPuzzle");
\r
24 //td.LinkEndChild(tid);
\r
26 root->appendChild(XMLCreateTextElement(doc,"Type",m_type));
\r
27 //tid->LinkEndChild(XMLCreateTextElement("Type",m_type));
\r
29 root->appendChild(XMLCreateCDATAElement(doc,"UUID",m_uuid));
\r
30 //tid->LinkEndChild(XMLCreateCDATAElement("UUID",m_uuid));
\r
32 root->appendChild(XMLCreateTextElement(doc,"MimeType",m_mimetype));
\r
33 //tid->LinkEndChild(XMLCreateTextElement("MimeType",m_mimetype));
\r
35 root->appendChild(XMLCreateTextElement(doc,"PuzzleData",m_puzzledata));
\r
36 //tid->LinkEndChild(XMLCreateTextElement("PuzzleData",m_puzzledata));
\r
39 //return std::string(tp.CStr());
\r
40 return GenerateXML(doc);
\r
43 void IntroductionPuzzleXML::Initialize()
\r
51 const bool IntroductionPuzzleXML::ParseXML(const std::string &xml)
\r
54 Poco::XML::DOMParser dp;
\r
60 Poco::AutoPtr<Poco::XML::Document> doc=dp.parseString(FixCDATA(xml));
\r
61 Poco::XML::Element *root=XMLGetFirstChild(doc,"IntroductionPuzzle");
\r
62 Poco::XML::Element *txt=NULL;
\r
64 txt=XMLGetFirstChild(root,"Type");
\r
67 if(txt->firstChild())
\r
69 m_type=SanitizeSingleString(txt->firstChild()->getNodeValue());
\r
72 txt=XMLGetFirstChild(root,"UUID");
\r
75 if(txt->firstChild())
\r
77 m_uuid=SanitizeSingleString(txt->firstChild()->getNodeValue());
\r
80 txt=XMLGetFirstChild(root,"MimeType");
\r
83 if(txt->firstChild())
\r
85 m_mimetype=SanitizeSingleString(txt->firstChild()->getNodeValue());
\r
88 txt=XMLGetFirstChild(root,"PuzzleData");
\r
91 if(txt->firstChild())
\r
93 m_puzzledata=SanitizeSingleString(txt->firstChild()->getNodeValue());
\r
107 td.Parse(xml.c_str());
\r
112 TiXmlHandle hnd(&td);
\r
116 txt=hnd.FirstChild("IntroductionPuzzle").FirstChild("Type").FirstChild().ToText();
\r
119 m_type=SanitizeSingleString(txt->ValueStr());
\r
122 txt=hnd.FirstChild("IntroductionPuzzle").FirstChild("UUID").FirstChild().ToText();
\r
125 m_uuid=SanitizeSingleString(txt->ValueStr());
\r
128 txt=hnd.FirstChild("IntroductionPuzzle").FirstChild("MimeType").FirstChild().ToText();
\r
131 m_mimetype=SanitizeSingleString(txt->ValueStr());
\r
134 txt=hnd.FirstChild("IntroductionPuzzle").FirstChild("PuzzleData").FirstChild().ToText();
\r
137 m_puzzledata=txt->ValueStr();
\r