Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. How to load xml file from resources using msxml?

How to load xml file from resources using msxml?

Scheduled Pinned Locked Moved XML / XSL
htmlxmlhelptutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    onestab
    wrote on last edited by
    #1

    IXLMDOMDocument2Ptr pDoc; // test.xml (UTF-8) encoded, : //你好, hello // check in IE, no problem. // resource type HTML, or BINARY tried. // ... create pDoc, find resource, loadresouce, // create IStream on HGlobal, everything seems ok // and i checked the dubug info, show xml content correctly, // and setting the IStream to the beginning of IStream // but... pDoc->async = VARIANT_FALSE; pDoc->load(_variant_t(pStream)); // FAILs, it complains that no top level element in xml. // but, when i write the stream into a disk file, // and load form file, it's OK !!! // if use loadXML((LPTSTR)hGlobal) the charactor shown is not correct.

    P 1 Reply Last reply
    0
    • O onestab

      IXLMDOMDocument2Ptr pDoc; // test.xml (UTF-8) encoded, : //你好, hello // check in IE, no problem. // resource type HTML, or BINARY tried. // ... create pDoc, find resource, loadresouce, // create IStream on HGlobal, everything seems ok // and i checked the dubug info, show xml content correctly, // and setting the IStream to the beginning of IStream // but... pDoc->async = VARIANT_FALSE; pDoc->load(_variant_t(pStream)); // FAILs, it complains that no top level element in xml. // but, when i write the stream into a disk file, // and load form file, it's OK !!! // if use loadXML((LPTSTR)hGlobal) the charactor shown is not correct.

      P Offline
      P Offline
      Per Nilsson
      wrote on last edited by
      #2

      It should not be much of a problem. I do it like this in a project (With all error handling removed. It just clutters up the example.) int CHookApp::LoadXML (int rsrc, MSXML2::IXMLDOMDocument2Ptr& xml, CString& errMsg) { HRSRC hXSLResourceInfoBlock; HGLOBAL hXSLResource; hXSLResourceInfoBlock = ::FindResource (m_hInstance, MAKEINTRESOURCE(rsrc), "XSL"); if (hXSLResourceInfoBlock) hXSLResource = LoadResource (m_hInstance, hXSLResourceInfoBlock); if (hXSLResourceInfoBlock == NULL || hXSLResource == NULL) return -1; try { _bstr_t xmlText ((char*)LockResource (hXSLResource)); if (xml->loadXML ( xmlText ) == VARIANT_FALSE) return -1; } catch (...) { return -1; } return 0; } I wonder why my empty lines are removed from the <pre> block above. It remained in another reply of mine....... -- modified at 5:03 Wednesday 14th December, 2005

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups