embed an image

  • Ignasi Mateos

    Ignasi Mateos - 2008-09-22

    Hi all,

    I would like to embed an image inside an xml. My idea is to use a CDATA node, but I'm not sure how to achieve this.

    Thanks in advance.

    Ignasi Mateos

    • Ignasi Mateos

      Ignasi Mateos - 2008-09-25

      Hi again,

      I'm trying to embed an image inside an XML, that's what I've done till now:


      ifstream imageFile;

      imageFile.open(imageFilename, ios::in | ios::binary);
      imageFile.seekg(0, ios::end);
      streamsize length = imageFile.tellg();

      if (length != 0)
          imageFile.seekg(0, ios::beg);

          char *pRaw = new char[length];
          imageFile.read((char*)pRaw, length);

          TiXmlElement *imageElem = new TiXmlElement("IMG");
          imageElem->SetAttribute("Data", pRaw);


      But it's only saved the fist four bits...Does anyone know what I'm doing wrong?

      Thanks in advance.


Log in to post a comment.