locked
Creating IXMLDOMDocument object.

    Question

  • Is there any opportunity to create IXMLDOMDocument COM object?

    Thank you!

     
    Wednesday, April 18, 2012 12:39 PM

All replies

  • Hello,

    Do you want to create a XML file in metro app? If so, you can use Windows.Data.Xml.Dom namespace
    http://msdn.microsoft.com/en-us/library/windows/apps/windows.data.xml.dom.aspx

    • Only COM function, you can access in metro for XML are these:
      CreateXmlReader
      CreateXmlReaderInputWithEncodingCodePage
      CreateXmlReaderInputWithEncodingName
      CreateXmlWriter
      CreateXmlWriterOutputWithEncodingCodePage
      CreateXmlWriterOutputWithEncodingName
      IXmlHttpRequest2
      IXmlHttpRequest2Callback
      IXmlReader
      IXmlReaderInput
      IXmlResolver
      IXmlWriter
      IXmlWriterOutput

    http://msdn.microsoft.com/en-us/library/windows/desktop/br205753.aspx

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, April 19, 2012 8:05 AM
  • IXMLDOMDocument is not an object, its an Interface. You can create a CoClass DOMDocument using CoCreateInstance

    #include <atlbase.h>

    #include <msxml2.h>

    ATL::CComPtr<IXMLDOMDocument> doc;

    doc.CoCreateInstance(__uuidof(DOMDocument2));

    Should work in Metro style apps too.

    Thursday, April 19, 2012 9:06 AM
  • CoCreateInstance is prohibited API in WinRT.
    Thursday, April 19, 2012 9:20 AM
  • No, its not. We use it

    HRESULT res = CoCreateInstance(
        CLSID_WICImagingFactory,
        nullptr,
        CLSCTX_INPROC_SERVER,
        IID_PPV_ARGS(&wicFactory)
        );

    and the code goes through the AppVerifier. MSFT please clarify.

    Thursday, April 19, 2012 9:45 AM
  • My old code use IXMLDOMDocument , so I want to reuse it in Metro style application. 
    Friday, April 20, 2012 5:52 AM
  • Actually you are using "CoCreateInstanceFromApp" call. You may check it by "Dependency Walker" tool.
    Friday, April 20, 2012 8:16 AM
  • What you mean? CoCreateInstance is not mapped to CoCreateInstanceFromApp in metro apps. According to the online API docs CoCreateInstance cannot be used. However, neither the compiler nor the AppVerifier are complaining.
    Friday, April 20, 2012 1:07 PM
  • I create WinRTComponent project, copy-past your code to project, then add reference to this project from Metro Application. You are right, that this code pass verification (do you mean "Windows App Certification Kit" asAppVerifier? ), but when I checked external dependencies with "Dependency Walker" tool, I see that this dll have only "CoCreateInstanceFromApp" call instead of "CoCreateInstance". I'm not very good in C++ development, but it seems strange that "CoCreateInstance" call can pass verification while it prohibited in documentation.  
    Friday, April 20, 2012 4:56 PM
  • Yes that is strange, Sergey. Any word from MSFT on this?
    Saturday, April 21, 2012 9:54 AM