LPSTR CPicture::GetContentXML() { LPSTR pszXML = NULL; CXmlDocument xmlDoc; CXmlElement* pBody = xmlDoc.AddElement(L"body"); CXmlElement* pContent = pBody->AddElement(L"content"); pContent->AddAttribute(L"id", m_contentID); pContent->AddAttribute(L"title", m_pwszFile); CXmlElement* pImage = pContent->AddElement(L"img"); pImage->AddAttribute(L"align", L"c"); pImage->AddAttribute(L"fit", L"screen"); pImage->AddAttribute(L"alt", m_pwszFile); // // The Image ID is the CONTENT_ID of the raw image bytes; // that is the same as this content ID, offset by // (CID_RAWIMAGE_FIRST - CID_XMLIMAGE_FIRST) // pImage->AddAttribute(L"id", m_contentID + (CID_RAWIMAGE_FIRST - CID_XMLIMAGE_FIRST)); CXmlElement* pLeftBtn = pContent->AddElement(L"btn"); pLeftBtn->AddAttribute(L"key", L"left"); pLeftBtn->AddAttribute(L"target", m_prevId); CXmlElement* pRightBtn = pContent->AddElement(L"btn"); pRightBtn->AddAttribute(L"key", L"right"); pRightBtn->AddAttribute(L"target", m_nextId); BSTR bstrXml; xmlDoc.GetXml(&bstrXml); // // The device handles UTF8 encoded strings, so the XML // needs to be converted from unicode to UTF8. // pszXML = AllocTaskUtf8String(bstrXml); ::SysFreeString(bstrXml); delete pBody; delete pContent; delete pImage; delete pLeftBtn; delete pRightBtn; return pszXML; }
LPSTR CTask::GetContentXML() { LPSTR pszXML = NULL; CXmlDocument xmlDoc; CXmlElement* pBody = xmlDoc.AddElement(L"body"); CXmlElement* pContent = pBody->AddElement(L"content"); pContent->AddAttribute(L"id", GetID()); pContent->AddAttribute(L"title", GetName()); CXmlElement* pCategory = pContent->AddElement(L"txt"); pCategory->AddText(m_wszCategory); CXmlElement* pDetails = pContent->AddElement(L"txt"); pDetails->AddText(m_wszDetails); CXmlElement* pDueTime = pContent->AddElement(L"txt"); pDueTime->AddText(m_wszTimeDue); CXmlElement* pLeftBtn = pContent->AddElement(L"btn"); pLeftBtn->AddAttribute(L"key", L"left"); pLeftBtn->AddAttribute(L"target", m_prevId); CXmlElement* pRightBtn = pContent->AddElement(L"btn"); pRightBtn->AddAttribute(L"key", L"right"); pRightBtn->AddAttribute(L"target", m_nextId); BSTR bstrXml; xmlDoc.GetXml(&bstrXml); printf("Sending Content: \n%ws\n\n", bstrXml); // // The device handles UTF8 encoded strings, so the XML // needs to be converted from unicode to UTF8. // pszXML = AllocTaskUtf8String(bstrXml); ::SysFreeString(bstrXml); return pszXML; }