예제 #1
0
/**
*  @brief
*    Parse incoming stream data
*/
void InputStream::ParseStream(const String &sStream)
{
	// Has the document been initialized yet?
	if (!m_pStream) {
		// Parse beginning of document
		m_cXml.Parse(sStream.GetASCII());

		// Get root element
		XmlElement *pRoot = m_cXml.GetRootElement();
		if (pRoot && pRoot->GetValue() == "stream:stream") {
			// Save stream element
			m_pStream = pRoot;

			// Callback function for stream element
			m_pJabberConnection->OnStreamStarted(*m_pStream);
		}
	} else {
		// Parse XML part
		XmlDocument cXml;
		cXml.Parse(sStream.GetASCII());
		XmlElement *pRoot = cXml.GetRootElement();
		if (pRoot) {
			// Add element
			XmlElement *pElement = static_cast<XmlElement*>(pRoot->Clone());
			m_pStream->LinkEndChild(*pElement);

			// Callback function for element
			m_pJabberConnection->OnElement(*pElement);
		}
	}
}
예제 #2
0
		bool Save()
		{
			std::ostringstream o;

			o << "<agenda>" << std::endl;
			o << "<notes>" << std::endl;

			for (int i=0; i<(int)events.size(); i++) {
				struct agenda_t *t = events[i];

				o << "<event day=\"" << t->day << "\" month=\"" << t->month << "\" year=\"" << t->year << "\">" << std::endl;
				o << t->event << std::endl;
				o << "</event>" << std::endl;
			}

			o << "</notes>" << std::endl;
			o << "</agenda>" << std::endl;

			XmlDocument doc;

			doc.Parse(o.str().c_str());

			if (doc.Error()) {
				return false;
			}

			doc.SaveFile(_file.c_str());

			return true;
		}