\r
std::string IdentityIntroductionXML::GetXML()\r
{\r
- TiXmlDocument td;\r
- TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8","");\r
- TiXmlElement *tid;\r
- TiXmlPrinter tp;\r
+ Poco::AutoPtr<Poco::XML::Document> doc=new Poco::XML::Document;\r
+ Poco::AutoPtr<Poco::XML::Element> root=doc->createElement("IdentityIntroduction");\r
\r
- td.LinkEndChild(tdec);\r
- tid=new TiXmlElement("IdentityIntroduction");\r
- td.LinkEndChild(tid);\r
+ doc->appendChild(root);\r
\r
- tid->LinkEndChild(XMLCreateCDATAElement("Identity",m_identity));\r
+ root->appendChild(XMLCreateCDATAElement(doc,"Identity",m_identity));\r
\r
- td.Accept(&tp);\r
- return std::string(tp.CStr());\r
+ return GenerateXML(doc);\r
}\r
\r
void IdentityIntroductionXML::Initialize()\r
const bool IdentityIntroductionXML::ParseXML(const std::string &xml)\r
{\r
FreenetSSK ssk;\r
- TiXmlDocument td;\r
- td.Parse(xml.c_str());\r
+ bool parsed=false;\r
+ Poco::XML::DOMParser dp;\r
\r
- if(!td.Error())\r
- {\r
- TiXmlText *txt;\r
- TiXmlHandle hnd(&td);\r
+ Initialize();\r
\r
- Initialize();\r
+ try\r
+ {\r
+ Poco::AutoPtr<Poco::XML::Document> doc=dp.parseString(FixCDATA(xml));\r
+ Poco::XML::Element *root=XMLGetFirstChild(doc,"IdentityIntroduction");\r
+ Poco::XML::Element *txt=NULL;\r
\r
- txt=hnd.FirstChild("IdentityIntroduction").FirstChild("Identity").FirstChild().ToText();\r
+ txt=XMLGetFirstChild(root,"Identity");\r
if(txt)\r
{\r
- m_identity=SanitizeSingleString(txt->ValueStr());\r
+ if(txt->firstChild())\r
+ {\r
+ m_identity=SanitizeSingleString(txt->firstChild()->getNodeValue());\r
+ }\r
}\r
+\r
ssk.SetPublicKey(m_identity);\r
if(ssk.ValidPublicKey()==false)\r
{\r
return false;\r
}\r
\r
- return true;\r
-\r
+ parsed=true;\r
}\r
- else\r
+ catch(...)\r
{\r
- return false;\r
}\r
\r
+ return parsed;\r
}\r